Files
fxhnt/tests/unit/test_combined_book_source.py

15 lines
736 B
Python

"""CombinedBookSource: RawFileSource reproduces load_crypto_panel; WarehouseSource (next task) matches it."""
from __future__ import annotations
import numpy as np
def test_raw_file_source_crypto_panel_matches_loader(tmp_path) -> None:
from fxhnt.application.combined_book_source import RawFileSource
cp = tmp_path / "crypto_pit"; cp.mkdir()
np.savez(cp / "BTCUSDT.npz", day=np.array([19000, 19001]), close=np.array([100.0, 110.0]))
np.savez(cp / "ETHUSDT.npz", day=np.array([19001]), close=np.array([50.0]))
days, syms, close, ret = RawFileSource(str(tmp_path)).crypto_panel()
assert days == [19000, 19001] and syms == ["BTCUSDT", "ETHUSDT"]
assert close[1, 0] == 110.0 and abs(ret[1, 0] - 0.10) < 1e-12