דלגו לתוכן
פתיחת RaamTrade

RC2_BUILTIN_ARG

תוכן זה אינו זמין עדיין בשפה שלך.

A built-in function was called with the wrong arguments.

What it means

The handful of built-ins RaamCode keeps are translated one-for-one into .NET calls, so each has a fixed shape the transpiler checks at compile time: how many arguments it takes, and — for len() — what kind of thing it can be pointed at. A call outside that shape has no translation, and a strategy that silently did nothing at a len() or min() site would be a very expensive kind of quiet.

len() — persistent-state collections only

len(...) reads the count of a class-body-declared list or dict. It is not a general-purpose length: there is nothing else in the language with a length to read.

class Bad(Strategy):
trade = Symbol()
sizing = FixedCapital()
bars_held = 0
def execute(self):
n = len(self.bars_held) # ❌ bars_held is a scalar, not a collection
if n > 0 and self.trade.is_flat:
self.buy(self.trade)

len("abc"), len(self.trade) and len(some_local) all fail the same way.

min() / max() — two or more values

Python’s single-iterable form (min(values)) has no equivalent here, because there are no iterables to pass. Both take two or more separate values:

class Bad2(Strategy):
trade = Symbol()
sizing = FixedCapital()
def execute(self):
lowest = min(self.trade.low) # ❌ one argument
if self.trade.close > lowest and self.trade.is_flat:
self.buy(self.trade)

print(*objects, sep=…, end=…, file=…, flush=…). Positional arguments are unlimited; file= and flush= are accepted for paste compatibility and ignored. Any other keyword is refused:

class Bad3(Strategy):
trade = Symbol()
sizing = FixedCapital()
def execute(self):
print("close", self.trade.close, foo=1) # ❌ unknown keyword
if self.trade.is_flat:
self.buy(self.trade)

The full shape list

Call Shape
int(x), float(x), bool(x), abs(x) exactly one argument
round(x) / round(x, digits) one or two arguments
min(a, b, …) / max(a, b, …) at least two arguments
len(x) exactly one, and it must be self.<list> or self.<dict>
print(…) any positionals; keywords limited to sep, end, file, flush
<timestamp>.weekday() no arguments

math.* functions are checked the same way but report RC2_MATH_ARITY, and a builtin that RaamCode refuses outright (sum, sorted, enumerate, eval, …) is SDK012, not this code.

How to fix it

Point len() at a declared collection, and give min / max the values to compare.

class Good(Strategy):
trade = Symbol()
sizing = FixedCapital()
recent_lows = [0.0]*5
def execute(self):
n = len(self.recent_lows) # ✅ a declared list
lowest = min(self.trade.low, self.trade.close) # ✅ two values
span = round(self.trade.high - lowest, 2) # ✅ round(x, digits)
print("bars in buffer", n, sep=": ") # ✅ sep is a real keyword
if span > 0 and self.trade.is_flat:
self.buy(self.trade, reason=f"Span {span:.2f}")
  • Python Subset — the complete allowed/blocked builtin list.
  • For Loops — len() and range() in their natural habitat.
  • Persistent State — declaring the lists and dicts len() accepts.
  • SDK012 — a builtin that isn’t available at all.