支持1d级别插针模型

This commit is contained in:
2026-08-25 09:23:30 +08:00
parent baddd7763d
commit c0df80154b
12 changed files with 299 additions and 65 deletions

View File

@@ -10,7 +10,9 @@ import pandas as pd
from cbpred.pipeline import (
CSV_COLUMNS,
DAY_MS,
EIGHT_H_MS,
aggregate_ohlcv,
aggregate_8h,
build_feature_dataset,
compute_indicators,
@@ -45,6 +47,33 @@ class PipelineTests(unittest.TestCase):
self.assertEqual(frame.iloc[0]["timestamp"], 0)
self.assertAlmostEqual(frame.iloc[0]["quote"], sum(row[6] for row in rows[:8]))
def test_aggregate_1d_drops_incomplete_buckets(self):
rows = make_hour_rows(0, 49)
frame = aggregate_ohlcv(rows, "1d")
self.assertEqual(len(frame), 2)
self.assertEqual(frame.iloc[0]["timestamp"], 0)
self.assertEqual(frame.iloc[1]["timestamp"], DAY_MS)
def test_daily_feature_dataset_uses_daily_continuity(self):
raw = aggregate_ohlcv(make_hour_rows(0, 24 * 80), "1d")
profiles = {
"x": {
"asset_atr_price_top20_median": 0.01,
"asset_quote_volume_top20_median_log": 12.0,
}
}
scaler = fit_asset_scaler(profiles)
dataset, _, _ = build_feature_dataset(
{"x": raw},
1,
int(raw.iloc[55]["timestamp"]),
int(raw.iloc[-1]["timestamp"] + DAY_MS),
scaler,
volatility_rank_threshold=0.0,
step_ms=DAY_MS,
)
self.assertFalse(dataset.empty)
def test_future_target_changes_but_past_features_do_not(self):
start = 0
raw = aggregate_8h(make_hour_rows(start, 8 * 70))