RC2_STATE_PARAM_CLASH
תוכן זה אינו זמין עדיין בשפה שלך.
<name>is already declared as a Param; it cannot also be persistent state.
What it means
A Param() is read-only for the lifetime of a run — its value is chosen by the optimizer, the walk-forward window, or the subscriber’s deploy form before the first bar, and every bar of that run sees the same number. Persistent state is the opposite: a slot your code writes.
One name cannot be both. If period = Param(20) is in the class body, self.period = 5 inside execute() is refused rather than silently shadowing the parameter the optimizer thinks it is sweeping.
Why it happens
class Bad(Strategy): period = Param(20, min=2, max=200) trade = Symbol() sizing = FixedCapital()
def execute(self): self.period = 5 # ❌ period is a Param — read-only if self.trade.is_flat: self.buy(self.trade)How to fix it
Give the state slot its own name and leave the Param alone.
class Good(Strategy): period = Param(20, min=2, max=200) trade = Symbol() sizing = FixedCapital() effective_period = 0
def execute(self): sma = SMA(self.period, on=self.trade)
self.effective_period = self.period # ✅ a slot of its own if sma.value > 0 and self.trade.is_flat: self.buy(self.trade)If what you actually wanted was a value that varies per bar, it was never a Param — declare it as state and drive it from the bar.
Related
Param()- Persistent State
RC2_STATE_SYMBOL_CLASH— the same collision against aSymbol()slot.RC2_STATE_RESERVED— the same collision against a platform property.