RC2_HELPER_ARITY
self.<helper>(...)— helper expects N argument(s), got M.
What it means
A helper call passes a different number of arguments than the helper declares. Helpers compile to fixed-signature methods, so the count has to match exactly: self is supplied for you and is never counted, and every other parameter must be passed at the call site.
Why it happens
Usually the helper’s signature changed and one call site didn’t follow:
class Bad(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): stop = self.stop_for(self.trade.close, 0.02) # ❌ two arguments, helper takes one
if self.trade.is_long and self.trade.close < stop: self.sell(self.trade, self.trade.position)
def stop_for(self, price): return price * 0.98Two things surprise people here:
selfis not an argument.def stop_for(self, price)is a one-argument helper;self.stop_for(x)is the correct call.- A default value does not make a parameter optional.
def stop_for(self, price, pct=0.02)still expects two arguments at every call site — the count is what is checked, not whether a default exists.
How to fix it
Match the count: either pass what the helper declares, or declare the parameter you want to pass.
class Good(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): stop = self.stop_for(self.trade.close, 2.0) # ✅ two arguments, two parameters
if self.trade.is_long and self.trade.close < stop: self.sell(self.trade, self.trade.position, reason="Stop hit")
if self.trade.is_flat: self.buy(self.trade)
def stop_for(self, price, pct): return price * (100 - pct) / 100Helpers can’t see execute()’s locals — including indicators — so a helper that needs an indicator value takes it as a parameter, which is exactly where the counts tend to drift apart. Change the signature and the call sites in the same edit.
Related
- Helper Methods — passing indicators and locals into a helper.
RC2_HELPER_SIGNATURE— the helper’s first parameter isn’tself.RC2_ENTRY_EXTRA_ARG— the same kind of miscount on an order verb.