RC2_ORDER_TYPE_CONFLICT
תוכן זה אינו זמין עדיין בשפה שלך.
One order verb carried both
stop=andlimit=.
What it means
An order rests at one level. stop= and limit= both name that level, and they name it on
opposite sides of the market — so a call carrying both is not one order with two prices, it is two
different orders written on one line.
class Bad(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): if self.trade.is_flat: self.buy(self.trade, stop=self.trade.close * 1.01, limit=self.trade.close * 0.99)Why it happens
The two order types are mirror images, and it is easy to reach for the wrong word:
| You wrote | Fires when | Fills at |
|---|---|---|
self.buy(..., stop=P) |
Price rises to P |
P, or the open if the bar gaps above it |
self.buy(..., limit=P) |
Price falls to P |
P, or the open if the bar gaps below it |
self.sell(..., stop=P) |
Price falls to P |
P, or the open if the bar gaps below it |
self.sell(..., limit=P) |
Price rises to P |
P, or the open if the bar gaps above it |
A stop is how you enter on confirmation (buy strength) or protect a position (sell weakness). A limit is how you enter on price improvement (buy the dip) or take profit (sell the rally).
RaamCode refuses the pair instead of picking one, because picking one would be right half the time and wrong invisibly the rest — you would get a fill at a price you never asked for and no diagnostic saying why.
How to fix it
Keep the one you meant.
class BuyTheDip(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): if self.trade.is_flat: self.buy(self.trade, limit=self.trade.close * 0.99, reason="Dip entry")class BuyTheBreakout(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): if self.trade.is_flat: self.buy(self.trade, stop=self.trade.close * 1.01, reason="Breakout entry")“But I want a stop-limit order”
There is no stop-limit verb. A RaamCode order carries one resting level, not a trigger price plus a
separate fill cap. Build the two-stage behaviour across two bars instead — test the trigger condition
in execute(), and place the resting limit on the bar after it becomes true, keeping the “armed” flag
in persistent state.
Protecting a position
If what you wanted was an entry plus a protective stop, those are two different mechanisms: the entry verb takes one level, and the protection is an exit rule, declared separately and checked tick-by-tick.
class LimitEntryProtected(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): self.stop_loss(2) # ✅ protection is a RULE, not a kwarg if self.trade.is_flat: self.buy(self.trade, limit=self.trade.close * 0.99, reason="Dip entry")