Bitcoin favicon, more strategies, default timeframe 5m
CI/CD / backend (pull_request) Successful in 5m21s
CI/CD / frontend (pull_request) Successful in 5m4s
CI/CD / build (pull_request) Skipped
CI/CD / deploy (pull_request) Skipped
CI/CD / cleanup (pull_request) Skipped

- 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:
matitos committed 2026-09-18 20:03:30 +00:00
1 parent 186a6949ee
commit c500fb7572
18 files changed
+488 -11

No files matched your search

@@ -0,0 +1,60 @@
from __future__ import annotations
from typing import ClassVar
from app.engine.indicators import ema, sma
from app.engine.strategies.base import Strategy, StrategyContext, register
from app.models import PositionSide
@register
class EmaCross(Strategy):
"""EMA crossover with an optional long-term trend filter."""
key: ClassVar[str] = "ema_cross"
name: ClassVar[str] = "EMA Crossover"
description: ClassVar[str] = (
"Open long when the fast EMA crosses above the slow EMA (and price is "
"above the trend filter, if enabled); exit on the opposite cross."
)
default_params: ClassVar[dict] = {
"fast": 9,
"slow": 21,
"trend_filter": 200,
"size": 1.0,
}
param_help: ClassVar[dict] = {
"fast": "Fast EMA period",
"slow": "Slow EMA period",
"trend_filter": "SMA trend filter period (0 disables)",
"size": "Fraction of equity per trade",
}
param_bounds: ClassVar[dict] = {"fast": (2, 100), "slow": (3, 300), "size": (0.01, 1.0)}
def on_candle(self, ctx: StrategyContext) -> None:
fast_period = int(self.params["fast"])
slow_period = int(self.params["slow"])
trend_period = int(self.params["trend_filter"])
needed = max(slow_period, trend_period) + 2
if len(ctx.closes) < needed:
return
fast = ema(ctx.closes, fast_period)
slow = ema(ctx.closes, slow_period)
f_prev, f_now = fast[-2], fast[-1]
s_prev, s_now = slow[-2], slow[-1]
if None in (f_prev, f_now, s_prev, s_now):
return
trend_ok = True
if trend_period > 0:
trend = sma(ctx.closes, trend_period)[-1]
trend_ok = trend is not None and ctx.price > trend
crossed_up = f_prev <= s_prev and f_now > s_now
crossed_down = f_prev >= s_prev and f_now < s_now
if ctx.is_flat and crossed_up and trend_ok:
ctx.enter_long(size=float(self.params["size"]), reason="EMA cross up")
elif ctx.side == PositionSide.LONG and crossed_down:
ctx.close(reason="EMA cross down")