RC2_ORDER_MISSING
תוכן זה אינו זמין עדיין בשפה שלך.
self.order()requires bothqty=anddirection=(BuyorSell).
What it means
self.order(...) is the raw verb — the escape hatch for pyramiding, hedging, and anything else the four directional verbs don’t express. It deliberately gives up their conveniences: nothing is auto-sized from the sizing model, and nothing is inferred from the current position. That leaves exactly two facts the engine cannot guess, so both are mandatory: how much (qty=), and which way (direction=Buy or direction=Sell).
Why it happens
One of the two was left off — usually direction=, because the surrounding if already reads like a direction:
class RawOrder(Strategy): trade = Symbol() sizing = FixedQuantity()
def execute(self): if self.trade.is_flat: self.order(self.trade, qty=5)The reverse — direction=Buy with no qty= — raises the same code. Note that order never falls back to the sizing model, even when one is declared: a raw order with no quantity is a missing argument, not a defaulted one.
How to fix it
State both.
class RawOrderFixed(Strategy): trade = Symbol() sizing = FixedQuantity()
def execute(self): if self.trade.is_flat: self.order(self.trade, qty=5, direction=Buy) if self.trade.is_long: self.order(self.trade, qty=5, direction=Sell, reason="scale out")If you are simply opening or closing a position, prefer the directional verbs — buy / sell_short are auto-sized, and sell / buy_to_cover read as what they are:
class DirectionalVerbs(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): if self.trade.is_flat: self.buy(self.trade) if self.trade.is_long: self.sell(self.trade, self.trade.position, reason="exit")Related
- Order Verbs — raw verb
- Sizing — what
orderopts out of. RC2_EXIT_NO_QTY— the exit verbs’ version of “say how much”.