This commit is contained in:
2026-08-29 11:00:27 +08:00
parent c0df80154b
commit 9e1b5e251a
11 changed files with 55 additions and 33 deletions

View File

@@ -19,8 +19,8 @@ def build_parser() -> argparse.ArgumentParser:
prepare = sub.add_parser("prepare", help="filter symbols, call banbot, export complete timeframe CSVs")
prepare.add_argument("--out-dir", type=Path, default=Path("data"))
prepare.add_argument("--banbot-dir", type=Path, default=Path("/home/ctyun/ban/banbot"))
prepare.add_argument("--banbot-config", type=Path, default=Path("/home/ctyun/ban/banbot/biz/config.yml"))
prepare.add_argument("--banbot-dir", type=Path, default=Path("/data/ban/banbot"))
prepare.add_argument("--banbot-config", type=Path, default=Path("/data/ban/banbot/biz/config.yml"))
prepare.add_argument("--dsn", default=None)
prepare.add_argument("--db-type", choices=["auto", "questdb", "timescale"], default="auto")
prepare.add_argument("--exchange", default="binance")

View File

@@ -48,6 +48,11 @@ def output_columns_for_timeframe(timeframe: str) -> tuple[str, ...]:
return (*OUTPUT_COLUMNS[:4], volume_column, *OUTPUT_COLUMNS[5:])
def default_output_dir(timeframe: str) -> Path:
timeframe_step_ms(timeframe)
return REPO_ROOT / f"predictions/latest_v1_{timeframe}"
def ensure_database(
banbot_config: Path,
dsn: str | None,
@@ -169,15 +174,20 @@ def build_predictions(data_dir: Path, artifact: Path, output_dir: Path) -> dict[
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description="Update banbot K-lines and predict with the current model")
parser.add_argument("--banbot-dir", type=Path, default=Path("/home/ctyun/ban/banbot"))
parser.add_argument("--banbot-dir", type=Path, default=Path("/data/ban/banbot"))
parser.add_argument(
"--banbot-config",
type=Path,
default=Path("/home/ctyun/ban/banbot/biz/config.yml"),
default=Path("/data/ban/banbot/biz/config.yml"),
)
parser.add_argument("--data-dir", type=Path, default=REPO_ROOT / "data")
parser.add_argument("--artifact", type=Path, default=REPO_ROOT / "artifacts/v1/model.joblib")
parser.add_argument("--output-dir", type=Path, default=REPO_ROOT / "predictions/latest_v1")
parser.add_argument(
"--output-dir",
type=Path,
default=None,
help="prediction output directory (default: predictions/latest_v1_<timeframe>)",
)
parser.add_argument("--history-months", type=int, default=36)
parser.add_argument("--holdout-months", type=int, default=10)
parser.add_argument("--min-age-days", type=int, default=730)
@@ -194,7 +204,9 @@ def main() -> None:
args = build_parser().parse_args()
data_dir = args.data_dir.resolve()
artifact = args.artifact.resolve()
output_dir = args.output_dir.resolve()
output_dir = (
args.output_dir if args.output_dir is not None else default_output_dir(args.timeframe)
).resolve()
ensure_database(args.banbot_config, args.dsn)
manifest = prepare_data(
out_dir=data_dir,

View File

@@ -143,7 +143,7 @@ def run_prediction(config: dict[str, Any], end_ms: int) -> tuple[dict[str, Any],
print(f"[prediction-service] running completed candle ending {_utc_label(end_ms)}", flush=True)
subprocess.run(command, cwd=working_dir, check=True)
output_dir = _config_path(
config, config["prediction"].get("output_dir", "predictions/latest_v1")
config, config["prediction"].get("output_dir", "predictions/latest_v1_8h")
).resolve()
report_path = output_dir / "report.json"
if not report_path.exists():