mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-28 07:57:44 +00:00
14395488b9
* update rdagent cmd * fix log error message * use multiProcessing.Process instead of subprocess.Popen * add traces to gitignore * add user interactor in RDLoop (finance scenarios) * add interactor (feedback, hypothesis) for quant scens * fix the test_end in qlib conf * add features init config, general instruction to qlib scenarios * set base features for based exp * fix bug when combine factors * move traces folder to git_ignore_folder * fix bug in features init * fix quant interact bug * fix logger warning error * bug fixes * modify rdagent logger, now it can set file output * adjust cli functions and fix logger bug * fix server port transport problem * update server_ui in cli * add web code * fix CI problem * black fix * update web ui README * update README * update readme
67 lines
2.0 KiB
Python
Executable File
67 lines
2.0 KiB
Python
Executable File
"""
|
|
Factor workflow with session control
|
|
"""
|
|
|
|
import asyncio
|
|
from pathlib import Path
|
|
from typing import Any, Optional
|
|
|
|
import fire
|
|
|
|
from rdagent.app.qlib_rd_loop.conf import FACTOR_PROP_SETTING
|
|
from rdagent.components.workflow.rd_loop import RDLoop
|
|
from rdagent.core.exception import CoderError, FactorEmptyError
|
|
from rdagent.log import rdagent_logger as logger
|
|
|
|
|
|
class FactorRDLoop(RDLoop):
|
|
skip_loop_error = (FactorEmptyError, CoderError)
|
|
skip_loop_error_stepname = "feedback"
|
|
|
|
def running(self, prev_out: dict[str, Any]):
|
|
exp = self.runner.develop(prev_out["coding"])
|
|
if exp is None:
|
|
logger.error(f"Factor extraction failed.")
|
|
raise FactorEmptyError("Factor extraction failed.")
|
|
logger.log_object(exp, tag="runner result")
|
|
return exp
|
|
|
|
|
|
def main(
|
|
path: Optional[str] = None,
|
|
step_n: Optional[int] = None,
|
|
loop_n: Optional[int] = None,
|
|
all_duration: str | None = None,
|
|
checkout: bool = True,
|
|
checkout_path: Optional[str] = None,
|
|
base_features_path: Optional[str] = None,
|
|
**kwargs,
|
|
):
|
|
"""
|
|
Auto R&D Evolving loop for fintech factors.
|
|
|
|
You can continue running session by
|
|
|
|
.. code-block:: python
|
|
|
|
dotenv run -- python rdagent/app/qlib_rd_loop/factor.py $LOG_PATH/__session__/1/0_propose --step_n 1 # `step_n` is a optional paramter
|
|
|
|
"""
|
|
if not checkout_path is None:
|
|
checkout = Path(checkout_path)
|
|
|
|
if path is None:
|
|
factor_loop = FactorRDLoop(FACTOR_PROP_SETTING)
|
|
else:
|
|
factor_loop = FactorRDLoop.load(path, checkout=checkout)
|
|
|
|
factor_loop._init_base_features(base_features_path)
|
|
if "user_interaction_queues" in kwargs and kwargs["user_interaction_queues"] is not None:
|
|
factor_loop._set_interactor(*kwargs["user_interaction_queues"])
|
|
factor_loop._interact_init_params()
|
|
asyncio.run(factor_loop.run(step_n=step_n, loop_n=loop_n, all_duration=all_duration))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
fire.Fire(main)
|