Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CoT strategy to code implementation #325

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rdagent/scenarios/qlib/experiment/factor_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def output_format(self) -> str:
def interface(self) -> str:
return self._interface

@property
def strategy(self) -> str:
return self._strategy

@property
def simulator(self) -> str:
return self._simulator
Expand All @@ -67,6 +71,8 @@ def get_scenario_all_desc(self) -> str:
{self.source_data}
The interface you should follow to write the runnable code:
{self.interface}
The strategy you should follow to write the code:
{self.strategy}
The output of your code should be in the format:
{self.output_format}
The simulator user can use to test your factor:
Expand Down
9 changes: 1 addition & 8 deletions rdagent/scenarios/qlib/experiment/prompts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ qlib_factor_interface: |-
User will write your python code into a python file and execute the file directly with "python {your_file_name}.py". You should calculate the factor values and save the result into a HDF5(H5) file named "result.h5" in the same directory as your python file. The result file is a HDF5(H5) file containing a pandas dataframe. The index of the dataframe is the "datetime" and "instrument", and the single column name is the factor name,and the value is the factor value. The result file should be saved in the same directory as your python file.

qlib_factor_strategy: |-
Ensure that for every step of data processing, the data format (including indexes) is clearly explained through comments.
Ensure that for every step of data processing, the data format (including indexes) is clearly explained through code comments.
Each transformation or calculation should be accompanied by a detailed description of how the data is structured, especially focusing on key aspects like whether the data has multi-level indexing, how to access specific columns or index levels, and any operations that affect the data shape (e.g., `reset_index()`, `groupby()`, `merge()`).
This step-by-step explanation will ensure clarity and accuracy in data handling. For example:
1. **Start with multi-level index**:
Expand Down Expand Up @@ -47,13 +47,6 @@ qlib_factor_strategy: |-
df['datetime'] = pd.to_datetime(df['datetime'])
other_df['datetime'] = pd.to_datetime(other_df['datetime'])
```

5. **Merge operations**:
```python
# When merging DataFrames, ensure you are merging on both 'datetime' and 'instrument'.
# If these are part of the index, reset the index before merging.
merged_df = pd.merge(df, other_df, on=['datetime', 'instrument'], how='inner')
```

qlib_factor_output_format: |-
Your output should be a pandas dataframe similar to the following example information:
Expand Down
Loading