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,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from app.engine.indicators import atr, ema, rolling_std, rsi, sma
|
||||
from app.schemas import Candle
|
||||
|
||||
|
||||
def candle(high: float, low: float, close: float, open_: float | None = None) -> Candle:
|
||||
return Candle(
|
||||
ts=0,
|
||||
open=open_ if open_ is not None else close,
|
||||
high=high,
|
||||
low=low,
|
||||
close=close,
|
||||
volume=1,
|
||||
)
|
||||
|
||||
|
||||
def test_sma() -> None:
|
||||
assert sma([1, 2, 3, 4, 5], 3) == [None, None, 2.0, 3.0, 4.0]
|
||||
|
||||
|
||||
def test_ema() -> None:
|
||||
assert ema([1, 2, 3, 4, 5], 3) == [None, None, 2.0, 3.0, 4.0]
|
||||
|
||||
|
||||
def test_rsi_monotonic_is_100() -> None:
|
||||
values = [float(i) for i in range(1, 20)]
|
||||
assert rsi(values, 14)[-1] == pytest.approx(100.0)
|
||||
|
||||
|
||||
def test_atr_flat_market_is_zero() -> None:
|
||||
candles = [candle(100, 100, 100) for _ in range(20)]
|
||||
assert atr(candles, 5)[-1] == pytest.approx(0.0)
|
||||
|
||||
|
||||
def test_rolling_std() -> None:
|
||||
result = rolling_std([1, 1, 1, 1], 2)
|
||||
assert result[-1] == pytest.approx(0.0)
|
||||
Reference in new issue
Block a user