22 lines
1.1 KiB
Python
22 lines
1.1 KiB
Python
"""Silver normalizers: raw bronze arrays -> canonical BarRecords (epoch-second ts)."""
|
|
from __future__ import annotations
|
|
|
|
import numpy as np
|
|
|
|
|
|
def test_normalize_futures_builds_adjusted_bars_with_epoch_second_ts() -> None:
|
|
from fxhnt.adapters.warehouse.silver_futures import normalize_futures
|
|
days = np.array([0, 1, 2], dtype=np.int64) # epoch-days
|
|
inst = np.array([10, 10, 20], dtype=np.int64) # roll on day 2
|
|
close = np.array([100.0, 102.0, 50.0])
|
|
high = np.array([101.0, 103.0, 51.0])
|
|
low = np.array([99.0, 101.0, 49.0])
|
|
bars = normalize_futures("ES", days, inst, close, high, low)
|
|
assert [b.ts for b in bars] == [0, 86_400, 172_800] # day * 86400
|
|
assert bars[2].close == bars[1].close # roll -> flat synthetic
|
|
assert bars[2].high / bars[2].close == 51.0 / 50.0 # range preserved
|
|
assert all(b.symbol == "ES" for b in bars)
|
|
|
|
# normalize_crypto (silver_crypto.py, the crypto_pit bronze normalizer) was retired along with the whole
|
|
# crypto_pit fetch/panel/ingest surface — Phase 0b Task 7e; Bybit ingest uses its own warehouse write path.
|