支持1d级别插针模型
This commit is contained in:
@@ -15,6 +15,8 @@ class ArtifactPathTests(unittest.TestCase):
|
||||
self.assertEqual(train.artifact_dir, Path("artifacts/v1"))
|
||||
self.assertEqual(run.artifact_dir, Path("artifacts/v1"))
|
||||
self.assertEqual(predict.artifact, Path("artifacts/v1/model.joblib"))
|
||||
daily = parser.parse_args(["prepare", "--timeframe", "1d"])
|
||||
self.assertEqual(daily.timeframe, "1d")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -6,7 +6,7 @@ from unittest.mock import patch
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from cbpred.latest_predict import OUTPUT_COLUMNS, build_predictions
|
||||
from cbpred.latest_predict import OUTPUT_COLUMNS, build_predictions, output_columns_for_timeframe
|
||||
|
||||
|
||||
class LatestPredictTests(unittest.TestCase):
|
||||
@@ -27,6 +27,9 @@ class LatestPredictTests(unittest.TestCase):
|
||||
),
|
||||
)
|
||||
|
||||
def test_output_columns_follow_timeframe(self):
|
||||
self.assertEqual(output_columns_for_timeframe("1d")[4], "quote_volume_usdt_1d")
|
||||
|
||||
def test_batch_skips_symbols_without_training_profiles(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user