Brokers¶
Live brokers are configured through live.broker and live.broker_config. The broker adapter is selected in live_engine.cpp.
Supported Adapters¶
alpacabinanceibwhen built withENABLE_IBAPI
Alpaca Broker Config¶
Keys in live.broker_config:
api_keysecret_keybase_urldata_urlstream_urlstream_auth_templatestream_subscribe_templatestream_unsubscribe_templatestream_ca_bundle_pathstream_expected_hostnameenable_streaming(trueorfalse)paper(trueorfalse)timeout_seconds
Notes:
- Alpaca market-data streaming now authenticates at the WebSocket handshake layer with
APCA-API-KEY-IDandAPCA-API-SECRET-KEY, matching Alpaca's documented Trading API WebSocket header auth flow. stream_auth_templateis retained as a compatibility fallback, but the normal Alpaca paper/demo path no longer depends on a post-connect auth message.
Binance Broker Config¶
Keys in live.broker_config:
api_keysecret_keybase_urlstream_urlstream_subscribe_templatestream_unsubscribe_templatestream_ca_bundle_pathstream_expected_hostnameenable_streaming(trueorfalse)timeout_secondsrecv_window_ms
Interactive Brokers Config¶
Keys in live.broker_config:
hostportclient_iddefaults.*for the adapter-wide contract defaultscontracts.<symbol>.*for per-symbol overrides
Supported Interactive Brokers contract fields:
symbol_overridesecurity_typeexchangecurrencyprimary_exchangelocal_symboltrading_classlast_trade_date_or_contract_monthrightmultiplierstrikecon_idinclude_expired
Example:
live:
broker: ib
broker_config:
host: 127.0.0.1
port: 7497
client_id: 7
defaults:
security_type: STK
exchange: SMART
currency: USD
contracts:
EURUSD:
security_type: CASH
exchange: IDEALPRO
FGBL:
security_type: FUT
exchange: EUREX
currency: EUR
local_symbol: FGBL MAR 27
include_expired: true
BMW_C72_DEC25:
security_type: OPT
symbol_override: BMW
exchange: EUREX
currency: EUR
last_trade_date_or_contract_month: 20251219
strike: 72
right: C
multiplier: "100"
Notes:
contracts.EURUSDautomatically mapsEURUSDto IBCASHfieldssymbol=EURandcurrency=USDunless you overridesymbol_overrideorcurrency.- Use
primary_exchangefor smart-routed non-US equities when the contract would otherwise be ambiguous. - Use
local_symbol,trading_class,multiplier, orcon_idfor futures and options that need extra disambiguation.
Notes¶
- The CLI fills Alpaca keys from
ALPACA_API_KEY,ALPACA_API_SECRET,ALPACA_PAPER_BASE_URL, andALPACA_STREAM_URLwhen missing. - The CLI fills Binance config from
BINANCE_API_KEY,BINANCE_SECRET_KEY,BINANCE_BASE_URL,BINANCE_STREAM_URL, andBINANCE_RECV_WINDOW_MSwhen missing. - The CLI fills Interactive Brokers config from
IB_HOST,IB_PORT, andIB_CLIENT_IDwhen missing. - Secret values in
live.broker_configcan also be expressed asvault://,aws-sm://,gcp-sm://, orazure-kv://references and are resolved before the live engine starts. - Brokers are constructed at engine startup. Invalid config fields typically fail at connect time.
- Capability tests now validate the supported time-in-force matrix for Alpaca, Binance, and IB.
- Env-gated startup smoke tests are available through
ctestfor Alpaca, Binance, and IB. - Lifecycle validation now uses
regimeflow_live_validatein either: submit_cancel_reconcilefill_reconcile
Verification Status¶
Alpaca¶
implemented: yesstartup-validated: yes, via env-gatedctestsmokepaper-validated: manualregimeflow_live_validaterun requiredproduction-validated: no blanket claim; account, market-data entitlements, and venue behavior remain deployment-specific
Binance¶
implemented: yesstartup-validated: yes, via env-gatedctestsmokepaper-validated: manualregimeflow_live_validaterun required for the exact Demo Mode or Testnet venue in useproduction-validated: no blanket claim; venue filters, permissions, and live-venue behavior remain deployment-specific
Interactive Brokers¶
implemented: yes when built withENABLE_IBAPIstartup-validated: yes, via env-gatedctestsmoke when IB API support is compiled inpaper-validated: manualregimeflow_live_validaterun required against the target TWS or Gateway sessionproduction-validated: no blanket claim; exchange, account, jurisdiction, login, and TWS/Gateway behavior remain deployment-specific
No broker is advertised as globally production-validated by the repository alone.
Interactive Brokers Access Boundary¶
Interactive Brokers availability is not only a code or packaging question. Access can also be blocked by Interactive Brokers account policy, login policy, jurisdiction, IP geolocation, or compliance restrictions.
Practical implication:
- A user may have a correct RegimeFlow build and correct
IB_HOST/IB_PORT/IB_CLIENT_IDvalues, but still be unable to run TWS or connect a paper session because IB blocks login or system access for that region or IP origin. - In that case, the limitation is external to RegimeFlow.
For users:
- If Interactive Brokers is unavailable in your region or from your current IP origin, use another supported broker adapter instead of assuming the RegimeFlow IB adapter is broken.
- If you need IB behavior adjusted for a different deployment environment, fork the project, apply the change, and open a pull request for review.
Next Step¶
live/production-readiness.md