Skip to content

datetime occurs multiple times #1909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bsq1989 opened this issue Apr 12, 2025 · 0 comments
Open

datetime occurs multiple times #1909

bsq1989 opened this issue Apr 12, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@bsq1989
Copy link

bsq1989 commented Apr 12, 2025

🐛 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

@bsq1989 bsq1989 added the bug Something isn't working label Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant