更新脚本
This commit is contained in:
@@ -10,6 +10,8 @@ from cbpred.latest_predict import (
|
||||
OUTPUT_COLUMNS,
|
||||
REPO_ROOT,
|
||||
build_predictions,
|
||||
default_artifact,
|
||||
default_data_dir,
|
||||
default_output_dir,
|
||||
output_columns_for_timeframe,
|
||||
)
|
||||
@@ -40,6 +42,32 @@ class LatestPredictTests(unittest.TestCase):
|
||||
self.assertEqual(default_output_dir("8h"), REPO_ROOT / "predictions/latest_v1_8h")
|
||||
self.assertEqual(default_output_dir("1d"), REPO_ROOT / "predictions/latest_v1_1d")
|
||||
|
||||
def test_default_inputs_follow_timeframe(self):
|
||||
self.assertEqual(default_data_dir("8h"), REPO_ROOT / "data")
|
||||
self.assertEqual(default_data_dir("1d"), REPO_ROOT / "data_1d")
|
||||
self.assertEqual(default_artifact("8h"), REPO_ROOT / "artifacts/v1/model.joblib")
|
||||
self.assertEqual(default_artifact("1d"), REPO_ROOT / "artifacts_1d/best/model.joblib")
|
||||
|
||||
def test_batch_rejects_stale_prediction_data(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
(root / "item.csv").write_text("timestamp,quote,close\n0,1,1\n")
|
||||
(root / "manifest.json").write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"timeframe": "1d",
|
||||
"end_ms": 2 * 24 * 60 * 60 * 1000,
|
||||
"symbols": [{"symbol": "TRAIN/USDT:USDT", "path": "item.csv"}],
|
||||
}
|
||||
)
|
||||
)
|
||||
with patch(
|
||||
"cbpred.latest_predict.joblib.load",
|
||||
return_value={"timeframe": "1d", "asset_profiles": {"TRAIN/USDT:USDT": {}}},
|
||||
):
|
||||
with self.assertRaisesRegex(RuntimeError, "incomplete 1d data"):
|
||||
build_predictions(root, root / "model.joblib", root / "output")
|
||||
|
||||
def test_batch_skips_symbols_without_training_profiles(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
|
||||
Reference in New Issue
Block a user