2025-07-28 14:19:41 +08:00
|
|
|
import os
|
|
|
|
|
from typing import Optional
|
|
|
|
|
|
2025-03-05 18:30:02 +08:00
|
|
|
from pydantic_settings import SettingsConfigDict
|
|
|
|
|
|
2024-11-25 16:27:34 +08:00
|
|
|
from rdagent.components.coder.CoSTEER.config import CoSTEERSettings
|
2025-07-28 14:19:41 +08:00
|
|
|
from rdagent.utils.env import (
|
|
|
|
|
CondaConf,
|
|
|
|
|
Env,
|
|
|
|
|
LocalEnv,
|
|
|
|
|
)
|
2024-05-21 22:48:41 +08:00
|
|
|
|
|
|
|
|
|
2024-11-25 16:27:34 +08:00
|
|
|
class FactorCoSTEERSettings(CoSTEERSettings):
|
2025-03-05 18:30:02 +08:00
|
|
|
model_config = SettingsConfigDict(env_prefix="FACTOR_CoSTEER_")
|
2024-08-09 13:27:33 +08:00
|
|
|
|
|
|
|
|
data_folder: str = "git_ignore_folder/factor_implementation_source_data"
|
|
|
|
|
"""Path to the folder containing financial data (default is fundamental data in Qlib)"""
|
|
|
|
|
|
|
|
|
|
data_folder_debug: str = "git_ignore_folder/factor_implementation_source_data_debug"
|
|
|
|
|
"""Path to the folder containing partial financial data (for debugging)"""
|
|
|
|
|
|
2024-11-06 13:14:35 +08:00
|
|
|
simple_background: bool = False
|
|
|
|
|
"""Whether to use simple background information for code feedback"""
|
|
|
|
|
|
2025-05-29 16:16:51 +08:00
|
|
|
file_based_execution_timeout: int = 3600
|
2024-08-09 13:27:33 +08:00
|
|
|
"""Timeout in seconds for each factor implementation execution"""
|
|
|
|
|
|
|
|
|
|
select_method: str = "random"
|
|
|
|
|
"""Method for the selection of factors implementation"""
|
2024-05-21 22:48:41 +08:00
|
|
|
|
2024-07-17 15:00:13 +08:00
|
|
|
python_bin: str = "python"
|
2024-08-09 13:27:33 +08:00
|
|
|
"""Path to the Python binary"""
|
2024-07-17 15:00:13 +08:00
|
|
|
|
2024-05-21 22:48:41 +08:00
|
|
|
|
2025-07-28 14:19:41 +08:00
|
|
|
def get_factor_env(
|
|
|
|
|
conf_type: Optional[str] = None,
|
|
|
|
|
extra_volumes: dict = {},
|
|
|
|
|
running_timeout_period: int = 600,
|
|
|
|
|
enable_cache: Optional[bool] = None,
|
|
|
|
|
) -> Env:
|
|
|
|
|
conf = FactorCoSTEERSettings()
|
|
|
|
|
if hasattr(conf, "python_bin"):
|
|
|
|
|
env = LocalEnv(conf=(CondaConf(conda_env_name=os.environ.get("CONDA_DEFAULT_ENV"))))
|
|
|
|
|
env.conf.extra_volumes = extra_volumes.copy()
|
|
|
|
|
env.conf.running_timeout_period = running_timeout_period
|
|
|
|
|
if enable_cache is not None:
|
|
|
|
|
env.conf.enable_cache = enable_cache
|
|
|
|
|
env.prepare()
|
|
|
|
|
return env
|
|
|
|
|
|
|
|
|
|
|
2024-11-25 16:27:34 +08:00
|
|
|
FACTOR_COSTEER_SETTINGS = FactorCoSTEERSettings()
|