Bitcoin favicon, more strategies, default timeframe 5m
- Add an SVG Bitcoin favicon and link it in index.html. - New indicators: macd() and roc(). - Five new strategies: macd_trend, bollinger_reversion, donchian_breakout, ema_cross, momentum (plus the existing sma_cross, rsi_reversion). - Default TIMEFRAME is now 5m (config, .env.example, compose, workflow, UI).
This commit is contained in:
1 parent
186a6949ee
commit
c500fb7572
18 files changed
+488
-11
No files matched your search
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from app.engine.indicators import atr, ema, rolling_std, rsi, sma
|
||||
from app.engine.indicators import atr, ema, macd, roc, rolling_std, rsi, sma
|
||||
from app.schemas import Candle
|
||||
|
||||
|
||||
@@ -38,3 +38,25 @@ def test_atr_flat_market_is_zero() -> None:
|
||||
def test_rolling_std() -> None:
|
||||
result = rolling_std([1, 1, 1, 1], 2)
|
||||
assert result[-1] == pytest.approx(0.0)
|
||||
|
||||
|
||||
def test_roc() -> None:
|
||||
values = [100.0, 110.0, 121.0, 100.0]
|
||||
out = roc(values, 2)
|
||||
assert out[0] is None and out[1] is None
|
||||
assert out[2] == pytest.approx(0.21)
|
||||
assert out[3] == pytest.approx(-0.09090909, rel=1e-4)
|
||||
|
||||
|
||||
def test_macd_shapes_and_crossover_sign() -> None:
|
||||
rising = [float(i) for i in range(1, 80)]
|
||||
macd_line, signal_line, histogram = macd(rising, 12, 26, 9)
|
||||
assert len(macd_line) == len(rising)
|
||||
assert macd_line[-1] is not None and signal_line[-1] is not None
|
||||
# In a steady uptrend MACD is positive (but can be below its signal after lag).
|
||||
assert macd_line[-1] > 0
|
||||
assert histogram[-1] == pytest.approx(macd_line[-1] - signal_line[-1])
|
||||
|
||||
falling = [float(i) for i in range(80, 0, -1)]
|
||||
macd_falling, _, _ = macd(falling, 12, 26, 9)
|
||||
assert macd_falling[-1] < 0
|
||||
Reference in new issue
Block a user