Canonical API reference for ForexSmartBot.
This document includes:
- Python core interfaces used by strategies/brokers/providers
- Broker adapter contracts and expected behavior
- REST/WebSocket cloud endpoints used by remote/mobile integrations
Implemented in forexsmartbot/core/interfaces.py.
Required methods:
connect() -> booldisconnect() -> Noneis_connected() -> boolget_price(symbol: str) -> Optional[float]submit_order(symbol: str, side: int, quantity: float, stop_loss: Optional[float], take_profit: Optional[float]) -> Optional[str]close_all(symbol: str) -> boolget_positions() -> Dict[str, Position]get_balance() -> floatget_equity() -> float
Implemented in forexsmartbot/core/interfaces.py.
Required methods:
get_data(symbol: str, start: str, end: str, interval: str = "1h") -> pd.DataFrameget_latest_price(symbol: str) -> Optional[float]get_historical_data(symbol: str, period: str = '1d', interval: str = '1h') -> pd.DataFrameis_available() -> bool
Implemented in forexsmartbot/core/interfaces.py.
Required methods:
nameparamsset_params(**kwargs)indicators(df)signal(df)volatility(df)stop_loss(df, entry_price, side)take_profit(df, entry_price, side)
Located in forexsmartbot/adapters/brokers/:
PaperBrokerMT4BrokerRestBrokerIBTWSBroker(Interactive Brokers TWS / IB Gateway)
Located in forexsmartbot/adapters/data/:
MT4ProviderOANDAProviderAlphaVantageProviderTwelveDataProviderStooqProviderYFinanceProviderMultiProvider(fallback chain)
Base URLs:
- REST API:
http://localhost:5000/api/v1 - WebSocket API:
ws://localhost:8765 - Remote Monitor:
http://localhost:8080
Typical endpoints:
GET /api/v1/healthGET /api/v1/account/balanceGET /api/v1/account/positionsPOST /api/v1/orders
Remote monitor (default http://localhost:8080):
GET /api/v1/health(public)GET /api/v1/status/positions/trades/alerts(auth)GET /api/v1/strategies/GET /api/v1/strategies/<name>— strategy health dashboardGET /api/v1/strategies/history/GET /api/v1/strategies/<name>/history— metrics history for chartsGET /api/v1/companion/health(public)GET /api/v1/companion/portfolio/positions/alerts/strategies(auth, read-only)GET /api/v1/companion/strategies/history(+ per-name) — companion historyPOST /api/v1/companion/pairing/session(auth) /POST .../pairing/redeem(public, single-use)GET|POST /api/v1/companion/actions+.../<id>/approve|reject— host-gated controlPOST|DELETE /api/v1/companion/devices/webhook— HTTPS webhook registration
Authentication:
- Bearer API key or
X-API-Keyon remote monitor / companion; JWT on cloud API server when configured.
sideconvention is+1(long/buy) and-1(short/sell).- Providers should return standardized OHLCV DataFrames with columns:
Open,High,Low,Close,Volume. - For integration examples, see
examples/anddocs/CLOUD_INTEGRATION_GUIDE.md.