Skip to content

datetime occurs multiple times #1909

@bsq1989

Description

@bsq1989

🐛 Bug Description

when change example config to alpha360, datetime occurs multiple times error occurs. i debug to recognize may be record_temp.py can fix to solve

To Reproduce

Steps to reproduce the behavior:

1.change the data handler to use alpha360

    dataset:
        class: DatasetH
        module_path: qlib.data.dataset
        kwargs:
            handler:
                class: Alpha360
                module_path: qlib.contrib.data.handler
                kwargs: *data_handler_config
            segments:
                train: [2022-04-12, 2024-08-12]
                valid: [2024-08-13, 2024-12-31]
                test: [2025-01-05, 2025-04-01]
  1. qrun config

Expected Behavior

no error

Screenshot

Image

Environment

Note: User could run cd scripts && python collect_info.py all under project directory to get system information
and paste them here directly.

  • Qlib version: 0.9.6
  • Python version:3.10
  • OS (Windows):

Additional Notes

after i change the code from workflow/record_temp.py function _generate

    def _generate(self, **kwargs):
        pred = self.load("pred.pkl")

        # replace the "<PRED>" with prediction saved before
        placeholder_value = {"<PRED>": pred}
        for k in "executor_config", "strategy_config":
            setattr(self, k, fill_placeholder(getattr(self, k), placeholder_value))
        # if the backtesting time range is not set, it will automatically extract time range from the prediction file
        dt_values = pred.index.get_level_values("datetime")
        if self.backtest_config["start_time"] is None:
            self.backtest_config["start_time"] = dt_values.min()
        if self.backtest_config["end_time"] is None:
            self.backtest_config["end_time"] = get_date_by_shift(dt_values.max(), 1)
......

to

    def _generate(self, **kwargs):
        pred = self.load("pred.pkl")

        # replace the "<PRED>" with prediction saved before
        placeholder_value = {"<PRED>": pred}
        for k in "executor_config", "strategy_config":
            setattr(self, k, fill_placeholder(getattr(self, k), placeholder_value))
        # if the backtesting time range is not set, it will automatically extract time range from the prediction file
        datetime_level = pred.index.names.index("datetime")
        dt_values = pred.index.get_level_values(datetime_level)
        if self.backtest_config["start_time"] is None:
            self.backtest_config["start_time"] = dt_values.min()
        if self.backtest_config["end_time"] is None:
            self.backtest_config["end_time"] = get_date_by_shift(dt_values.max(), 1)
....

the error disapper

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions