Files
fxhnt/tests/integration/test_crypto_pit_panel.py
2026-06-18 23:02:00 +02:00

28 lines
1.1 KiB
Python

import numpy as np
from fxhnt.adapters.data.crypto_pit_panel import CryptoPitPanelSource
def _write(tmp_path, sym, days, close, qvol, funding):
np.savez(tmp_path / f"{sym}.npz",
day=np.array(days, dtype=np.int64), close=np.array(close, dtype=float),
qvol=np.array(qvol, dtype=float), funding=np.array(funding, dtype=float))
def test_loads_panel_from_npz(tmp_path):
_write(tmp_path, "AAA", [100, 101], [1.0, 1.1], [2e6, 2e6], [0.001, 0.0012])
_write(tmp_path, "DEAD", [100], [5.0], [1e6], [0.003])
src = CryptoPitPanelSource(str(tmp_path))
panel = src.panel()
assert set(panel) == {"AAA", "DEAD"}
assert panel["AAA"][100] == (1.0, 2e6, 0.001) # (close, qvol, funding)
assert panel["DEAD"][100] == (5.0, 1e6, 0.003)
assert sorted(src.all_days()) == [100, 101]
def test_panel_ignores_non_npz_and_is_deterministic(tmp_path):
_write(tmp_path, "BBB", [100], [1.0], [3e6], [0.0])
(tmp_path / "notes.txt").write_text("ignore me")
a = CryptoPitPanelSource(str(tmp_path)).panel()
b = CryptoPitPanelSource(str(tmp_path)).panel()
assert a == b and set(a) == {"BBB"}