FastAPI backend with a single-strategy async engine, paper and Binance brokers, pure-python indicators, a backtester that shares the engine's portfolio math, and a Vue dashboard with a live WebSocket feed. Adds the Gitea Actions CI/CD workflow that deploys to Traefik via docker_default.
21 lines
694 B
Python
21 lines
694 B
Python
from __future__ import annotations
|
|
|
|
from app.broker.base import Broker, Fill
|
|
from app.broker.binance import TESTNET_URL, BinanceBroker
|
|
from app.broker.paper import PaperBroker
|
|
from app.config import Settings
|
|
from app.market.binance import BASE_URL
|
|
|
|
|
|
def build_broker(settings: Settings) -> Broker:
|
|
if settings.mode == "live":
|
|
return BinanceBroker(
|
|
api_key=settings.exchange_api_key,
|
|
api_secret=settings.exchange_api_secret,
|
|
base_url=TESTNET_URL if settings.exchange_sandbox else BASE_URL,
|
|
)
|
|
return PaperBroker(fee_bps=settings.fee_bps, slippage_bps=settings.slippage_bps)
|
|
|
|
|
|
__all__ = ["Broker", "Fill", "PaperBroker", "build_broker"]
|