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,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterator
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
|
||||
from app.config import REPO_ROOT, get_settings
|
||||
from app.models import Base
|
||||
|
||||
_settings = get_settings()
|
||||
|
||||
|
||||
def _normalize_url(url: str) -> tuple[str, dict]:
|
||||
connect_args: dict = {}
|
||||
if url.startswith("sqlite"):
|
||||
prefix, _, path = url.partition("sqlite:///")
|
||||
if path and not path.startswith("/"):
|
||||
url = f"{prefix}sqlite:///{REPO_ROOT / path}"
|
||||
connect_args = {"check_same_thread": False}
|
||||
return url, connect_args
|
||||
|
||||
|
||||
_url, _connect_args = _normalize_url(_settings.database_url)
|
||||
engine = create_engine(_url, connect_args=_connect_args, pool_pre_ping=True)
|
||||
SessionLocal = sessionmaker(bind=engine, autoflush=False, expire_on_commit=False)
|
||||
|
||||
|
||||
def init_db() -> None:
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
|
||||
def get_session() -> Iterator[Session]:
|
||||
session = SessionLocal()
|
||||
try:
|
||||
yield session
|
||||
finally:
|
||||
session.close()
|
||||
Reference in new issue
Block a user