- RiskManager halts + flattens on max daily loss / drawdown, caps position size and trades per day; adds a manual kill switch (POST /api/bot/kill). - Telegram and webhook notifications on trades, errors and halts. - Optional API bearer token on /api, injected server-side by the frontend nginx so the browser never sees it. - Kraken and Coinbase market data (public); Coinbase live broker. Live on an unsupported exchange now errors instead of silently falling back to paper. - Strategy presets backed by the StrategyConfig table (CRUD API + UI). - Idempotent additive-column migration so existing SQLite databases upgrade in place (fixes the new strategy_configs.name column).
33 lines
855 B
Python
33 lines
855 B
Python
from __future__ import annotations
|
|
|
|
from app.config import Settings
|
|
from app.market.base import MarketData
|
|
from app.market.binance import BinanceMarketData
|
|
from app.market.coinbase import CoinbaseMarketData
|
|
from app.market.fake import FakeMarketData
|
|
from app.market.kraken import KrakenMarketData
|
|
|
|
_FEEDS: dict[str, type[MarketData]] = {
|
|
"binance": BinanceMarketData,
|
|
"binanceus": BinanceMarketData,
|
|
"kraken": KrakenMarketData,
|
|
"coinbase": CoinbaseMarketData,
|
|
}
|
|
|
|
|
|
def build_market_data(settings: Settings) -> MarketData:
|
|
try:
|
|
feed_cls = _FEEDS[settings.exchange.lower()]
|
|
except KeyError:
|
|
raise ValueError(
|
|
f"unsupported exchange: {settings.exchange}. available: {sorted(_FEEDS)}"
|
|
) from None
|
|
return feed_cls()
|
|
|
|
|
|
__all__ = [
|
|
"FakeMarketData",
|
|
"MarketData",
|
|
"build_market_data",
|
|
]
|