mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-01 17:37:43 +00:00
Revised to enable logging of backtesting in Qlib & storing of rich-text-description in Trace
This commit is contained in:
@@ -27,6 +27,15 @@ class Scenario(ABC):
|
||||
def simulator(self) -> str:
|
||||
"""Simulator description"""
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def rich_style_description(self) -> str:
|
||||
"""Rich style description to present"""
|
||||
|
||||
@abstractmethod
|
||||
def get_scenario_all_desc(self) -> str:
|
||||
"""Combine all the description together"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@ class QlibModelScenario(Scenario):
|
||||
@property
|
||||
def simulator(self) -> str:
|
||||
return prompt_dict["qlib_model_simulator"]
|
||||
|
||||
@property
|
||||
def rich_style_description(self)->str:
|
||||
return "Below is QlibModel Evolving Automatic R&D Demo."
|
||||
|
||||
def get_scenario_all_desc(self) -> str:
|
||||
return f"""Background of the scenario:
|
||||
|
||||
@@ -39,7 +39,11 @@ else:
|
||||
# Load the specified file from the latest recorder
|
||||
metrics = pd.Series(latest_recorder.list_metrics())
|
||||
|
||||
|
||||
output_path = Path(__file__).resolve().parent / "qlib_res.csv"
|
||||
metrics.to_csv(output_path)
|
||||
|
||||
print(f"Output has been saved to {output_path}")
|
||||
|
||||
ret_data_frame = latest_recorder.load_object("portfolio_analysis/report_normal_1day.pkl")
|
||||
ret_data_frame.to_pickle("ret.pkl")
|
||||
|
||||
@@ -36,6 +36,9 @@ class QlibFBWorkspace(FBWorkspace):
|
||||
env=run_env,
|
||||
)
|
||||
|
||||
ret_df = pd.read_pickle(self.workspace_path / "ret.pkl")
|
||||
logger.log_object(ret_df, tag="returns") # TODO: tag
|
||||
|
||||
csv_path = self.workspace_path / "qlib_res.csv"
|
||||
|
||||
if not csv_path.exists():
|
||||
|
||||
Reference in New Issue
Block a user