From 71a01fb5577ae8326072020a8de49361f16bd3de Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Thu, 2 Apr 2026 10:08:32 +0900 Subject: refactor: migrate to US stocks with Alpaca API - Replace Binance/ccxt with Alpaca REST client (paper + live) - Add MOC (Market on Close) strategy for overnight gap trading - Wire sentiment into strategy engine main loop - Add EMA + bullish candle entry filters to Asian RSI - Remove crypto-specific exchange factory - Update config: Alpaca keys replace Binance keys - 399 tests passing, lint clean --- .../strategy-engine/tests/test_moc_strategy.py | 28 +++++++++++++++++++--- .../strategy-engine/tests/test_sentiment_wiring.py | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'services/strategy-engine/tests') diff --git a/services/strategy-engine/tests/test_moc_strategy.py b/services/strategy-engine/tests/test_moc_strategy.py index 10a6720..1928a28 100644 --- a/services/strategy-engine/tests/test_moc_strategy.py +++ b/services/strategy-engine/tests/test_moc_strategy.py @@ -1,6 +1,8 @@ """Tests for MOC (Market on Close) strategy.""" + import sys from pathlib import Path + sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from datetime import datetime, timezone @@ -61,8 +63,28 @@ def test_moc_no_signal_outside_buy_window(): def test_moc_buy_signal_in_window(): s = _make_strategy(ema_period=3) # Build up history with some oscillation so RSI settles in the 30-70 range - prices = [150, 149, 151, 148, 152, 149, 150, 151, 148, 150, - 149, 151, 150, 152, 151, 153, 152, 154, 153, 155] + prices = [ + 150, + 149, + 151, + 148, + 152, + 149, + 150, + 151, + 148, + 150, + 149, + 151, + 150, + 152, + 151, + 153, + 152, + 154, + 153, + 155, + ] signals = [] for i, p in enumerate(prices): sig = s.on_candle(_candle(p, hour=20, minute=i * 2, volume=200.0)) @@ -105,7 +127,7 @@ def test_moc_no_buy_on_bearish_candle(): for i in range(8): s.on_candle(_candle(150, hour=20, minute=i * 3, volume=200.0)) # Bearish candle (open > close) - sig = s.on_candle(_candle(149, hour=20, minute=30, open_price=151)) + s.on_candle(_candle(149, hour=20, minute=30, open_price=151)) # May or may not signal depending on other criteria, but bearish should reduce chances # Just verify no crash diff --git a/services/strategy-engine/tests/test_sentiment_wiring.py b/services/strategy-engine/tests/test_sentiment_wiring.py index f1a816f..e0052cb 100644 --- a/services/strategy-engine/tests/test_sentiment_wiring.py +++ b/services/strategy-engine/tests/test_sentiment_wiring.py @@ -1,4 +1,5 @@ """Test sentiment is wired into strategy engine.""" + import sys from pathlib import Path -- cgit v1.2.3