diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 09:44:43 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 09:44:43 +0900 |
| commit | b9d21e2e2f7ae096c2f8a01bb142a685683b5b90 (patch) | |
| tree | a031989228ded9ff1e6d47840124ea5dcc9a9a3c /services/strategy-engine/strategies/combined_strategy.py | |
| parent | bb2e387f870495703fd663ca8f525028c3a8ced5 (diff) | |
feat: add market sentiment filters (Fear & Greed, CryptoPanic, CryptoQuant)
- SentimentProvider: fetches Fear & Greed Index (free, no key),
CryptoPanic news sentiment (free key), CryptoQuant exchange
netflow (free key)
- SentimentData: aggregated should_buy/should_block logic
- Fear < 30 = buy opportunity, Greed > 80 = block buying
- Negative news < -0.5 = block buying
- Exchange outflow = bullish, inflow = bearish
- Integrated into Asian Session RSI strategy as entry filter
- All providers optional — disabled when API key missing
- 14 sentiment tests + 386 total tests passing
Diffstat (limited to 'services/strategy-engine/strategies/combined_strategy.py')
| -rw-r--r-- | services/strategy-engine/strategies/combined_strategy.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/services/strategy-engine/strategies/combined_strategy.py b/services/strategy-engine/strategies/combined_strategy.py index 907d9c5..ba92485 100644 --- a/services/strategy-engine/strategies/combined_strategy.py +++ b/services/strategy-engine/strategies/combined_strategy.py @@ -53,7 +53,9 @@ class CombinedStrategy(BaseStrategy): self._trade_history[strategy_name].append(is_win) # Keep only last N results if len(self._trade_history[strategy_name]) > self._history_window: - self._trade_history[strategy_name] = self._trade_history[strategy_name][-self._history_window:] + self._trade_history[strategy_name] = self._trade_history[strategy_name][ + -self._history_window : + ] def _get_adaptive_weight(self, strategy_name: str, base_weight: float) -> float: """Get weight adjusted by recent performance.""" @@ -90,10 +92,14 @@ class CombinedStrategy(BaseStrategy): effective_weight = self._get_adaptive_weight(strategy.name, weight) if signal.side == OrderSide.BUY: score += effective_weight * signal.conviction - reasons.append(f"{strategy.name}:BUY({effective_weight}*{signal.conviction:.2f})") + reasons.append( + f"{strategy.name}:BUY({effective_weight}*{signal.conviction:.2f})" + ) elif signal.side == OrderSide.SELL: score -= effective_weight * signal.conviction - reasons.append(f"{strategy.name}:SELL({effective_weight}*{signal.conviction:.2f})") + reasons.append( + f"{strategy.name}:SELL({effective_weight}*{signal.conviction:.2f})" + ) normalized = score / total_weight # Range: -1.0 to 1.0 |
