-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version of factor idea proposal (#46)
* update all code * save code * update first version of factor proposal * change a comment * remove a useless comment --------- Co-authored-by: xuyang1 <[email protected]>
- Loading branch information
1 parent
fc91f36
commit 637ad10
Showing
17 changed files
with
354 additions
and
98 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from pydantic_settings import BaseSettings | ||
|
||
|
||
class PropSetting(BaseSettings): | ||
"""""" | ||
|
||
scen: str = "rdagent.scenarios.qlib.experiment.factor_experiment.QlibFactorScenario" | ||
hypothesis_gen: str = "rdagent.scenarios.qlib.factor_proposal.QlibFactorHypothesisGen" | ||
hypothesis2experiment: str = "rdagent.scenarios.qlib.factor_proposal.QlibFactorHypothesis2Experiment" | ||
qlib_factor_coder: str = "rdagent.components.task_implementation.factor_implementation.CoSTEER.CoSTEERFG" | ||
qlib_factor_runner: str = "rdagent.scenarios.qlib.task_generator.data.QlibFactorRunner" | ||
qlib_factor_summarizer: str = "rdagent.scenarios.qlib.task_generator.feedback.QlibFactorExperiment2Feedback" | ||
|
||
evolving_n: int = 10 | ||
|
||
|
||
PROP_SETTING = PropSetting() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
TODO: Factor Structure RD-Loop | ||
""" | ||
|
||
# import_from | ||
from rdagent.app.qlib_rd_loop.conf import PROP_SETTING | ||
from rdagent.core.proposal import ( | ||
Experiment2Feedback, | ||
Hypothesis2Experiment, | ||
HypothesisGen, | ||
HypothesisSet, | ||
Trace, | ||
) | ||
from rdagent.core.task_generator import TaskGenerator | ||
from rdagent.core.utils import import_class | ||
|
||
scen = import_class(PROP_SETTING.scen)() | ||
|
||
hypothesis_gen: HypothesisGen = import_class(PROP_SETTING.hypothesis_gen)(scen) | ||
|
||
hypothesis2experiment: Hypothesis2Experiment = import_class(PROP_SETTING.hypothesis2experiment)() | ||
|
||
qlib_factor_coder: TaskGenerator = import_class(PROP_SETTING.qlib_factor_coder)() | ||
qlib_factor_runner: TaskGenerator = import_class(PROP_SETTING.qlib_factor_runner)() | ||
|
||
qlib_factor_summarizer: Experiment2Feedback = import_class(PROP_SETTING.qlib_factor_summarizer)() | ||
|
||
|
||
trace = Trace(scen=scen) | ||
hs = HypothesisSet(trace=trace) | ||
for _ in range(PROP_SETTING.evolving_n): | ||
hypothesis = hypothesis_gen.gen(trace) | ||
exp = hypothesis2experiment.convert(hs) | ||
exp = qlib_factor_coder.generate(exp) | ||
exp = qlib_factor_runner.generate(exp) | ||
feedback = qlib_factor_summarizer.summarize(exp) | ||
|
||
trace.hist.append((hypothesis, exp, feedback)) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
from pathlib import Path | ||
|
||
from rdagent.components.task_implementation.factor_implementation.factor import ( | ||
FactorExperiment, | ||
) | ||
from rdagent.components.task_implementation.factor_implementation.utils import ( | ||
get_data_folder_intro, | ||
) | ||
from rdagent.core.prompts import Prompts | ||
from rdagent.core.proposal import Scenario | ||
|
||
prompt_dict = Prompts(file_path=Path(__file__).parent / "prompts.yaml") | ||
|
||
QlibFactorExperiment = FactorExperiment | ||
|
||
|
||
class QlibFactorScenario(Scenario): | ||
@property | ||
def background(self) -> str: | ||
return prompt_dict["qlib_factor_background"] | ||
|
||
@property | ||
def source_data(self) -> str: | ||
return get_data_folder_intro() | ||
|
||
@property | ||
def interface(self) -> str: | ||
return prompt_dict["qlib_factor_interface"] | ||
|
||
@property | ||
def simulator(self) -> str: | ||
return prompt_dict["qlib_factor_simulator"] | ||
|
||
def get_scenario_all_desc(self) -> str: | ||
return f"""Background of the scenario: | ||
{self.background} | ||
The source data you can use: | ||
{self.source_data} | ||
The interface you should follow to write the runnable code: | ||
{self.interface} | ||
The simulator user can use to test your factor: | ||
{self.simulator} | ||
""" |
Oops, something went wrong.