qlib icon indicating copy to clipboard operation
qlib copied to clipboard

An error when I do 30min trade.

Open DOCCA0 opened this issue 1 year ago • 0 comments

ValueError: can't find a freq from [Freq(30min)] that can resample to 1min!

code:


###################################
# prediction, backtest & analysis
###################################
port_analysis_config = {
    "executor": {
        "class": "SimulatorExecutor",
        "module_path": "qlib.backtest.executor",
        "kwargs": {
            "time_per_step": "30min",
            "generate_portfolio_metrics": True,
        },
    },
    "strategy": {
        "class": "TopkDropoutStrategy",
        "module_path": "qlib.contrib.strategy.signal_strategy",
        "kwargs": {
            "model": model,
            "dataset": dataset,
            "topk": 10,
            "n_drop": 5,
        },
    },
    "backtest": {
        "start_time": "2024-08-01 00:00:00",
        "end_time": "2024-10-30 23:59:59",
        "account": 10000,
        "benchmark": benchmark,
        "exchange_kwargs": {
            "freq": "30min",
            "limit_threshold": 0.095,
            "deal_price": "close",
            "open_cost": 0.0005,
            "close_cost": 0.0015,
            "min_cost": 5,
        },
    },
}

# backtest and analysis
with R.start(experiment_name="backtest_analysis"):
    recorder = R.get_recorder(recorder_id=rid, experiment_name="train_model")
    model = recorder.load_object("trained_model")

    # prediction
    recorder = R.get_recorder()
    ba_rid = recorder.id
    sr = SignalRecord(model, dataset, recorder)
    sr.generate()

    # backtest & analysis
    par = PortAnaRecord(recorder, port_analysis_config, "day")
    par.generate()

DOCCA0 avatar Oct 24 '24 11:10 DOCCA0