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,63 @@
from __future__ import annotations
from typing import ClassVar
from app.engine.strategies.base import Strategy, StrategyContext, register
from app.models import PositionSide
@register
class BollingerReversion(Strategy):
"""Buy the lower Bollinger band, exit at the middle band."""
key: ClassVar[str] = "bollinger_reversion"
name: ClassVar[str] = "Bollinger Reversion"
description: ClassVar[str] = (
"Enter long when the close falls below the lower Bollinger band and exit "
"when it returns to the middle band (SMA). Optional ATR stop."
)
default_params: ClassVar[dict] = {
"period": 20,
"num_std": 2.0,
"atr_period": 14,
"atr_stop_mult": 0.0,
"size": 1.0,
}
param_help: ClassVar[dict] = {
"period": "Bollinger lookback",
"num_std": "Band width in standard deviations",
"atr_period": "ATR lookback for the stop",
"atr_stop_mult": "Stop distance in ATRs (0 disables)",
"size": "Fraction of equity per trade",
}
param_bounds: ClassVar[dict] = {
"period": (5, 100),
"num_std": (0.5, 4.0),
"atr_stop_mult": (0.0, 10.0),
"size": (0.01, 1.0),
}
def on_candle(self, ctx: StrategyContext) -> None:
period = int(self.params["period"])
if len(ctx.closes) < period:
return
middle = ctx.sma(period)
deviation = ctx.std(period)
if middle is None or deviation is None:
return
lower = middle - float(self.params["num_std"]) * deviation
if ctx.is_flat and ctx.price < lower:
stop = None
mult = float(self.params["atr_stop_mult"])
if mult > 0:
atr_value = ctx.atr(int(self.params["atr_period"]))
if atr_value:
stop = ctx.price - mult * atr_value
ctx.enter_long(
size=float(self.params["size"]),
stop_loss=stop,
reason="close below lower band",
)
elif ctx.side == PositionSide.LONG and ctx.price >= middle:
ctx.close(reason="close back at middle band")