Beispiel #1
0
    def _prepare_calender_cache(self):
        """preload the calendar for cache"""

        # This code used the copy-on-write feature of Linux to avoid calculating the calendar multiple times in the subprocess
        # This code may accelerate, but may be not useful on Windows and Mac Os
        Cal.calendar(freq="1min")
        get_calendar_day(freq="1min")
Beispiel #2
0
        },
    }
    """initialize qlib"""
    # use yahoo_cn_1min data
    QLIB_INIT_CONFIG = {**HIGH_FREQ_CONFIG, **SPEC_CONF}
    print(QLIB_INIT_CONFIG)
    provider_uri = QLIB_INIT_CONFIG.get("provider_uri")
    if not exists_qlib_data(provider_uri):
        print(f"Qlib data is not found in {provider_uri}")
        GetData().qlib_data(target_dir=provider_uri,
                            interval="1min",
                            region=REG_CN)
    qlib.init(**QLIB_INIT_CONFIG)

    Cal.calendar(freq="1min")
    get_calendar_day(freq="1min")

    # get data
    dataset = init_instance_by_config(task["dataset"])
    xtrain, xtest = dataset.prepare(["train", "test"])
    print(xtrain, xtest)
    xtrain.to_csv("xtrain.csv")

    dataset_backtest = init_instance_by_config(task["dataset_backtest"])
    backtest_train, backtest_test = dataset_backtest.prepare(["train", "test"])
    print(backtest_train, backtest_test)

    # model initialization
    model = init_instance_by_config(task["model"])
    dataset = init_instance_by_config(task["dataset"])