Crypto trading bot: engine, brokers, backtester, dashboard, deploy
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.
This commit is contained in:
1 parent
98028248c2
commit
9c3bee87ac
73 files changed
+9759
-1
No files matched your search
@@ -0,0 +1,63 @@
|
||||
# ruff: noqa: E402, I001
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
os.environ["DATABASE_URL"] = "sqlite:///./data/test_trader.db"
|
||||
os.environ["FEE_BPS"] = "0"
|
||||
os.environ["SLIPPAGE_BPS"] = "0"
|
||||
os.environ["POLL_INTERVAL"] = "3600"
|
||||
os.environ["STARTING_BALANCE"] = "10000"
|
||||
|
||||
from collections.abc import Iterator # noqa: E402
|
||||
|
||||
import pytest # noqa: E402
|
||||
|
||||
from app.broker.paper import PaperBroker # noqa: E402
|
||||
from app.config import Settings # noqa: E402
|
||||
from app.market.fake import FakeMarketData # noqa: E402
|
||||
from app.models import Base # noqa: E402
|
||||
from app.db import engine as db_engine # noqa: E402
|
||||
from app.runtime import Runtime # noqa: E402
|
||||
from app.store import Store # noqa: E402
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def settings() -> Settings:
|
||||
return Settings(
|
||||
mode="paper",
|
||||
symbol="BTC/USDT",
|
||||
timeframe="1m",
|
||||
poll_interval=3600,
|
||||
starting_balance=10_000,
|
||||
fee_bps=0,
|
||||
slippage_bps=0,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_db() -> Iterator[None]:
|
||||
Base.metadata.drop_all(bind=db_engine)
|
||||
Base.metadata.create_all(bind=db_engine)
|
||||
yield
|
||||
Base.metadata.drop_all(bind=db_engine)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def store() -> Store:
|
||||
return Store()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def market() -> FakeMarketData:
|
||||
return FakeMarketData.from_closes([100.0, 101.0, 102.0])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def runtime(settings: Settings, store: Store, market: FakeMarketData) -> Runtime:
|
||||
return Runtime(
|
||||
settings,
|
||||
store,
|
||||
feed_factory=lambda _settings: market,
|
||||
broker_factory=lambda _settings: PaperBroker(fee_bps=0, slippage_bps=0),
|
||||
)
|
||||
Reference in new issue
Block a user