| monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x1220cbda0>
|
|
|
| def test_load_dataset_from_snapshots_joins_scan_and_outcomes(monkeypatch):
|
| """load_dataset_from_snapshots joins raw scan candidates (per day) with
|
| realized short outcomes into CriticalSellCase — mocked I/O (no NFS/Alpaca)."""
|
| from datetime import date as _d
|
| from types import SimpleNamespace
|
|
|
| # One trading day, two candidates.
|
| def fake_scan(**kwargs):
|
| return [
|
| {"symbol": "AAA", "cmf": -0.40, "score": 90, "priority": "critical_sell",
|
| "direction": "short", "summary": "", "snapshot_path": "x",
|
| "row": {"short_ratio": 0.5}},
|
| {"symbol": "BBB", "cmf": -0.35, "score": 80, "priority": "critical_sell",
|
| "direction": "short", "summary": "", "snapshot_path": "y", "row": {}},
|
| ]
|
|
|
| def fake_outcomes(detections_by_day, **kwargs):
|
| out = []
|
| for day, dets in detections_by_day.items():
|
| for d in dets:
|
| out.append(SimpleNamespace(
|
| detection_day=day, entry_day=day, symbol=d.symbol,
|
| cmf=d.cmf, score=d.score, entry_open=10.0, same_day_close=9.8,
|
| next_close=9.7, t0_short_ret_pct=2.0, t1_short_ret_pct=3.0,
|
| ))
|
| return out
|
|
|
| > import rtrader.services.channel_scalp_service as _svc
|
|
|
| tests/services/test_critical_sell_ga.py:97:
|
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
| rtrader/services/channel_scalp_service.py:3335: in <module>
|
| _ensure_ray_task()
|
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
|
|
| def _ensure_ray_task():
|
| global _ray_evaluate_symbol
|
| if _ray_evaluate_symbol is not None:
|
| return
|
| import ray
|
|
|
| > @ray.remote(num_cpus=1, max_retries=2, retry_exceptions=True)
|
| ^^^^^^^^^^
|
| E AttributeError: module 'ray' has no attribute 'remote'
|
|
|
| rtrader/services/channel_scalp_service.py:3305: AttributeError
|