Files
NexQuant/rdagent/app/benchmark/factor/eval.py
T

43 lines
1.3 KiB
Python
Raw Normal View History

2024-07-25 18:22:57 +08:00
import os
import pickle
import time
from pathlib import Path
from pprint import pprint
2024-06-14 12:59:44 +08:00
2024-07-30 18:06:48 +08:00
from rdagent.app.qlib_rd_loop.conf import FACTOR_PROP_SETTING
2024-07-17 15:00:13 +08:00
from rdagent.components.benchmark.conf import BenchmarkSettings
from rdagent.components.benchmark.eval_method import FactorImplementEval
2024-07-25 18:22:57 +08:00
from rdagent.core.scenario import Scenario
from rdagent.core.utils import import_class
from rdagent.log import rdagent_logger as logger
2024-07-25 18:22:57 +08:00
from rdagent.scenarios.qlib.experiment.factor_experiment import QlibFactorScenario
from rdagent.scenarios.qlib.factor_experiment_loader.json_loader import (
FactorTestCaseLoaderFromJsonFile,
)
2024-07-25 18:22:57 +08:00
2024-09-06 17:18:52 +08:00
if __name__ == "__main__":
# 1.read the settings
bs = BenchmarkSettings()
2024-06-14 12:59:44 +08:00
2024-09-06 17:18:52 +08:00
# 2.read and prepare the eval_data
test_cases = FactorTestCaseLoaderFromJsonFile().load(bs.bench_data_path)
2024-06-14 12:59:44 +08:00
2024-09-06 17:18:52 +08:00
# 3.declare the method to be tested and pass the arguments.
2024-06-27 09:39:17 +01:00
2024-09-06 17:18:52 +08:00
scen: Scenario = import_class(FACTOR_PROP_SETTING.scen)()
generate_method = import_class(bs.bench_method_cls)(scen=scen)
# 4.declare the eval method and pass the arguments.
eval_method = FactorImplementEval(
method=generate_method,
test_cases=test_cases,
scen=scen,
catch_eval_except=True,
test_round=bs.bench_test_round,
)
2024-06-14 12:59:44 +08:00
2024-09-06 17:18:52 +08:00
# 5.run the eval
res = eval_method.eval()
2024-07-25 18:22:57 +08:00
2024-09-06 17:18:52 +08:00
# 6.save the result
logger.log_object(res)