RC2_STATE_RESERVED
תוכן זה אינו זמין עדיין בשפה שלך.
<name>is a strategy-level reserved property; it cannot be used as persistent state.
What it means
Four names are strategy-level properties the platform computes and hands you every bar:
| Property | What it is |
|---|---|
self.capital |
Current equity. |
self.initial_capital |
The equity the run started with. |
self.bar_count |
Bars seen so far, 1-based. |
self.ready |
Whether every declared indicator has finished warming up. |
They are read-only. Declaring persistent state under one of those names — in the class body or by assigning to it in execute() — would shadow the real property, and every later read would silently return your value instead of the platform’s.
Why it happens
class Bad(Strategy): trade = Symbol() sizing = FixedCapital() bar_count = 0 # ❌ shadows the platform's bar counter
def execute(self): if self.trade.is_flat: self.buy(self.trade)The same refusal fires for an assignment inside execute() — self.capital = 100000 is not a way to set your starting equity.
How to fix it
Rename your slot. The reserved property stays readable alongside it.
class Good(Strategy): trade = Symbol() sizing = FixedCapital() my_bar_count = 0 # ✅ a name of your own
def execute(self): self.my_bar_count += 1
# the platform's own counter is still readable if self.bar_count > 20 and self.trade.is_flat: self.buy(self.trade, reason=f"equity {self.capital:.0f}")Starting capital is a run setting, not a strategy value — it is chosen on the backtest or deploy form, and self.initial_capital reports it back to you.
Related
- Strategy Properties
- Persistent State
RC2_PARAM_RESERVED— the same collision, from aParam()instead.RC2_STATE_PARAM_CLASH/RC2_STATE_SYMBOL_CLASH— state colliding with your own Param or Symbol names.