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

RC2_SYMBOL_BROKER

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

Symbol()’s broker= must be a string literal.

What it means

broker= locks a slot to one broker. Like the ticker, it is a compile-time constraint — it is emitted as a RequiredBroker attribute on the compiled strategy and enforced when a subscriber binds the slot. A bare identifier or a variable cannot be read at compile time, so the transpiler refuses it instead of compiling a slot that silently accepts any broker.

Note what this diagnostic does not check: the transpiler does not know the platform’s broker list. Any string literal compiles — a broker name that doesn’t exist fails later, when the slot is bound, not here.

Why it happens

The quotes are missing, so the broker name parses as an identifier:

class UnquotedBroker(Strategy):
trade = Symbol("SPY", broker=tradestation)
sizing = FixedCapital()
def execute(self):
if self.trade.is_flat:
self.buy(self.trade)

This bites hardest right after a session declaration, because sessions are written unquoted (session=USEquityDaily is an identifier the catalog resolves) while brokers are plain strings.

How to fix it

Quote the broker name.

class BrokerLocked(Strategy):
trade = Symbol("SPY", broker="tradestation", session=USEquityDaily)
sizing = FixedCapital()
def execute(self):
if self.trade.is_flat:
self.buy(self.trade)

If the strategy doesn’t actually depend on a particular broker, leave broker= off — an unconstrained slot is bindable by more subscribers.