Skip to content
Open RaamTrade

Strategy Properties

Read-only properties exposed on self. All are updated by the platform before each execute() call.

Property Type What it is
self.capital decimal Current equity. Updated after every fill.
self.initial_capital decimal Starting capital for this run. Constant.
self.bar_count int Bars processed since warmup ended. Starts at 0 on the first execute().
self.ready bool All indicators warmed up. Rarely needed — execute() only runs after this is True.

There is deliberately no “bars since entry” property — track it yourself with one line of persistent state (see below).

Reading them

class TimeBasedExit(Strategy):
trade = Symbol()
sizing = FixedCapital()
def execute(self):
rsi = RSI(14, on=self.trade)
# How many bars since I opened my position? Track it in persistent state.
if self.trade.is_long:
self.bars_held = self.bars_held + 1 # int state, auto-inits to 0
else:
self.bars_held = 0
# Drawdown from peak — useful for adaptive sizing
drawdown_pct = (self.initial_capital - self.capital) / self.initial_capital * 100
if self.trade.is_flat and drawdown_pct < 20 and rsi.value < 30:
self.buy(self.trade)
if self.trade.is_long and self.bars_held > 30 and rsi.value < 50:
self.sell(self.trade, self.trade.position, reason="Time-based exit")

Read-only

You cannot assign to any of these:

self.capital = 100000 # ❌ RC2_STATE_RESERVED — capital is computed
self.bar_count = 0 # ❌ RC2_STATE_RESERVED — bar_count is read-only

All four names are reserved, in the class body and in execute() alike — see RC2_STATE_RESERVED.

For your own counters, persistent state (self.my_counter = 0) is the right tool.

One logic, every mode

Your execute() runs identically in backtest, optimization, paper and live — there is deliberately no mode or warmup-phase flag on self. Determinism is the guarantee: the same code and the same bars produce the same signals everywhere, so a backtest is always an honest preview of live behavior. The platform owns everything mode-specific (bar delivery, order routing, and warmup-flagging of runner lead-in trades — see Warmup →).