RC2_EXEC_STMT
Unsupported statement in
execute().
What it means
execute() accepts a fixed list of statement kinds: if / elif / else, for, assignment (plain and augmented), pass, a bare return, and calls that do something — an order verb, an exit rule, a helper, print(...). A statement outside that list is refused, because the transpiler has no translation for it and a silently-dropped statement in a trading strategy is worse than a compile error.
Why it happens
By far the most common cause is a ... placeholder left where the logic hasn’t been written yet. ... is a legal Python expression, but as a statement it computes a value and throws it away — RaamCode has no such thing:
class Bad(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): if self.trade.is_flat: ... # ❌ — `...` is not a placeholder in RaamCodeThe same applies to any bare expression statement: a line that is only self.trade.close, or only rsi.value, reads a value and does nothing with it.
Loop and error-handling constructs land here too:
class Bad2(Strategy): trade = Symbol() sizing = FixedCapital() total = 0.0
def execute(self): while self.total < 10: # ❌ — no `while` in RaamCode self.total = self.total + 1.0| Statement | Status |
|---|---|
... (Ellipsis), a bare expression |
Refused — computes and discards |
while |
Refused — every strategy is a per-bar function; loop over range(...) or a state collection instead |
break, continue |
Refused — loops are bounded and run to completion |
try / except / finally, raise |
Refused — error handling belongs to the platform |
with, del, global, nonlocal |
Refused — see Python Subset |
pass |
Accepted — this is the placeholder that works |
How to fix it
Put a real statement in the branch, or use pass — Python’s own placeholder, and the one RaamCode accepts.
class Good(Strategy): trade = Symbol() sizing = FixedCapital()
def execute(self): rsi = RSI(14, on=self.trade)
if rsi.value < 30 and self.trade.is_flat: self.buy(self.trade, reason="RSI oversold") elif rsi.value > 70 and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="RSI overbought") else: pass # ✅ `pass` is a statement; `...` is notA strategy whose execute() emits no order at all still compiles, so there is never a reason to leave a placeholder behind to “keep it valid” — delete the empty branch instead.
Related
- Python Subset — the full list of what the language takes and what it refuses.
- For Loops — the only loop form, and the replacement for
while. RC2_IMPORT_BLOCKED—importhas its own diagnostic.SDK012— a blocked builtin inside an otherwise legal statement.