diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 10:08:32 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 10:08:32 +0900 |
| commit | 71a01fb5577ae8326072020a8de49361f16bd3de (patch) | |
| tree | 7515f1e5d67d308cefbaa0d9ee8a13984f20b73f /services/strategy-engine/tests/test_moc_strategy.py | |
| parent | 6f162e4696e8e90fcbd6ca84d0ad7f0d187dfb01 (diff) | |
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
Diffstat (limited to 'services/strategy-engine/tests/test_moc_strategy.py')
| -rw-r--r-- | services/strategy-engine/tests/test_moc_strategy.py | 28 |
1 files changed, 25 insertions, 3 deletions
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 |
