mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-04 10:47:43 +00:00
d6ce70b551
* fix model input shape bug and costeer_model bug * fix a bug * fix a bug in docker result extraction * a system-level optimization * add a filter of stdout * update * add stdout to model * model training_hyperparameters update * quant scenario * update some quant settings * llm choose action * Thompson Sampling Bandit for action choosing * refine both scens * add trace messages for quant scen * fix some bugs * fix some bugs * update * update * update * fix * fix * fix * update for merge * fix ci * fix some bugs * fix ci * fix ci * fix ci * fix ci * refactor * default qlib4rdagent local env downloading * fix ci * fix ci * fix a bug * fix ci * fix: align all prompts on template (#908) * use template to render all prompts * fix CI --------- Co-authored-by: Xu Yang <xuyang1@microsoft.com> * add fin_quant in cli * fix a bug * fix ci * fix some bugs * refactor * remove the columns in hypothesis if no value generated in this column * fix a bug * fix ci * fix conda env * add qlib gitignore * remove existed qlib folder & install torch in qlib conda * fix workspace ui in feedback * align model config in coder and runner in docker or conda * fix CI * fix CI --------- Co-authored-by: Xu Yang <peteryang@vip.qq.com> Co-authored-by: Xu Yang <xuyang1@microsoft.com>
80 lines
2.7 KiB
Python
80 lines
2.7 KiB
Python
from copy import deepcopy
|
|
from pathlib import Path
|
|
|
|
from rdagent.components.coder.factor_coder.factor import (
|
|
FactorExperiment,
|
|
FactorFBWorkspace,
|
|
FactorTask,
|
|
)
|
|
from rdagent.core.experiment import Task
|
|
from rdagent.core.scenario import Scenario
|
|
from rdagent.scenarios.qlib.experiment.utils import get_data_folder_intro
|
|
from rdagent.scenarios.qlib.experiment.workspace import QlibFBWorkspace
|
|
from rdagent.utils.agent.tpl import T
|
|
|
|
|
|
class QlibFactorExperiment(FactorExperiment[FactorTask, QlibFBWorkspace, FactorFBWorkspace]):
|
|
def __init__(self, *args, **kwargs) -> None:
|
|
super().__init__(*args, **kwargs)
|
|
self.experiment_workspace = QlibFBWorkspace(template_folder_path=Path(__file__).parent / "factor_template")
|
|
self.stdout = ""
|
|
|
|
|
|
class QlibFactorScenario(Scenario):
|
|
def __init__(self) -> None:
|
|
super().__init__()
|
|
self._background = deepcopy(T(".prompts:qlib_factor_background").r())
|
|
self._source_data = deepcopy(get_data_folder_intro())
|
|
self._output_format = deepcopy(T(".prompts:qlib_factor_output_format").r())
|
|
self._interface = deepcopy(T(".prompts:qlib_factor_interface").r())
|
|
self._strategy = deepcopy(T(".prompts:qlib_factor_strategy").r())
|
|
self._simulator = deepcopy(T(".prompts:qlib_factor_simulator").r())
|
|
self._rich_style_description = deepcopy(T(".prompts:qlib_factor_rich_style_description").r())
|
|
self._experiment_setting = deepcopy(T(".prompts:qlib_factor_experiment_setting").r())
|
|
|
|
@property
|
|
def background(self) -> str:
|
|
return self._background
|
|
|
|
def get_source_data_desc(self, task: Task | None = None) -> str:
|
|
return self._source_data
|
|
|
|
@property
|
|
def output_format(self) -> str:
|
|
return self._output_format
|
|
|
|
@property
|
|
def interface(self) -> str:
|
|
return self._interface
|
|
|
|
@property
|
|
def simulator(self) -> str:
|
|
return self._simulator
|
|
|
|
@property
|
|
def rich_style_description(self) -> str:
|
|
return self._rich_style_description
|
|
|
|
@property
|
|
def experiment_setting(self) -> str:
|
|
return self._experiment_setting
|
|
|
|
def get_scenario_all_desc(
|
|
self, task: Task | None = None, filtered_tag: str | None = None, simple_background: bool | None = None
|
|
) -> str:
|
|
"""A static scenario describer"""
|
|
if simple_background:
|
|
return f"""Background of the scenario:
|
|
{self.background}"""
|
|
return f"""Background of the scenario:
|
|
{self.background}
|
|
The source data you can use:
|
|
{self.get_source_data_desc(task)}
|
|
The interface you should follow to write the runnable code:
|
|
{self.interface}
|
|
The output of your code should be in the format:
|
|
{self.output_format}
|
|
The simulator user can use to test your factor:
|
|
{self.simulator}
|
|
"""
|