Skip to content

Commit 9683d1f

Browse files
authored
docs: Added documentation for Qlib Factor Loop, Qlib Model Loop, Data-Copilot, and Paper-Copilot scenario. (#178)
* Fixed some bugs introduced during refactoring. * Added docs for four scenrios. * Update factor_from_report_w_sc.py
1 parent b7aebf8 commit 9683d1f

File tree

5 files changed

+370
-106
lines changed

5 files changed

+370
-106
lines changed

docs/scens/data_agent_fin.rst

Lines changed: 98 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Finance Data Agent
55
=====================
66

77

8-
**Automated Quantitative Trading & Iterative Factors Evolution 🤖**
8+
**🤖 Automated Quantitative Trading & Iterative Factors Evolution**
99
-------------------------------------------------------------------
1010

11-
Background
12-
~~~~~~~~~~
11+
📖 Background
12+
~~~~~~~~~~~~~~
1313
In the dynamic world of quantitative trading, **factors** are the secret weapons that traders use to harness market inefficiencies.
1414

1515
These powerful tools—ranging from straightforward metrics like price-to-earnings ratios to intricate discounted cash flow models—unlock the potential to predict stock prices with remarkable precision.
@@ -18,8 +18,13 @@ By tapping into this rich vein of data, quantitative traders craft sophisticated
1818
Embrace the power of factors, and you're not just trading; you're strategically outsmarting the market.
1919

2020

21-
Introduction
22-
~~~~~~~~~~~~
21+
🎥 Demo
22+
~~~~~~~~~~
23+
TODO: Here should put a video of the demo.
24+
25+
26+
🌟 Introduction
27+
~~~~~~~~~~~~~~~~
2328
In this scenario, our agent illustrates the iterative process of hypothesis generation, knowledge construction, and decision-making.
2429

2530
It highlights how financial factors evolve through continuous feedback and refinement.
@@ -43,7 +48,7 @@ Here's an enhanced outline of the steps:
4348
**Step 4 : Backtesting with Qlib 📉**
4449

4550
- Integrate the full dataset into the factor implementation code and prepare the factor library.
46-
- Perform backtesting using the Alpha158+ model in Qlib to assess the factor's effectiveness and performance.
51+
- Conduct backtesting using the Alpha158 plus newly developed factors and LGBModel in Qlib to evaluate the new factors' effectiveness and performance.
4752

4853
+----------------+------------+----------------+----------------------------------------------------+
4954
| Dataset | Model | Factors | Data Split |
@@ -59,27 +64,101 @@ Here's an enhanced outline of the steps:
5964

6065

6166
**Step 5 : Feedback Analysis 🔍**
62-
- Analyze backtest results.
63-
- Incorporate feedback to refine hypotheses.
67+
68+
- Analyze backtest results to assess performance.
69+
- Incorporate feedback to refine hypotheses and improve the model.
6470

6571
**Step 6 :Hypothesis Refinement ♻️**
66-
- Refine hypotheses based on feedback and repeat the process.
6772

68-
Demo
69-
~~~~~~~~~~
70-
.. TODO
73+
- Refine hypotheses based on feedback from backtesting.
74+
- Repeat the process to continuously improve the model.
7175

72-
Quick Start
76+
Quick Start
7377
~~~~~~~~~~~~~~~~~
7478

75-
To quickly start the Automated Quantitative Trading & Iterative Factors Evolution process, run the following command in your terminal within the `rdagent` virtual environment:
79+
You can try our demo by running the following command:
7680

77-
.. code-block:: sh
81+
- 🐍 Create a Conda Environment
82+
- Create a new conda environment with Python (3.10 and 3.11 are well tested in our CI):
83+
84+
.. code-block:: sh
85+
86+
conda create -n rdagent python=3.10
7887
79-
python rdagent/app/qlib_rd_loop/factor_w_sc.py
88+
- Activate the environment:
8089

90+
.. code-block:: sh
8191
82-
Usage of modules
83-
~~~~~~~~~~~~~~~~~
84-
TODO: Show some examples:
92+
conda activate rdagent
93+
94+
- 🛠️ Run Make Files
95+
- Navigate to the directory containing the MakeFile and set up the development environment:
96+
97+
.. code-block:: sh
98+
99+
make dev
100+
101+
- 📦 Install Pytorch
102+
- Install Pytorch and related libraries:
103+
104+
.. code-block:: sh
105+
106+
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
107+
pip3 install torch_geometric
108+
109+
- ⚙️ Environment Configuration
110+
- Place the `.env` file in the same directory as the `.env.example` file.
111+
- The `.env.example` file contains the environment variables required for users using the OpenAI API (Please note that `.env.example` is an example file. `.env` is the one that will be finally used.)
112+
113+
- Export each variable in the .env file:
114+
115+
.. code-block:: sh
116+
117+
export $(grep -v '^#' .env | xargs)
118+
119+
- If you want to change the default environment variables, you can refer to `Env Config`_ below
120+
121+
- 🚀 Run the Application
122+
.. code-block:: sh
123+
124+
python rdagent/app/qlib_rd_loop/factor_w_sc.py
125+
126+
127+
🛠️ Usage of modules
128+
~~~~~~~~~~~~~~~~~~~~~
129+
130+
.. _Env Config:
131+
132+
- **Env Config**
133+
134+
The following environment variables can be set in the `.env` file to customize the application's behavior:
135+
- **Path to the folder containing private data (default fundamental data in Qlib):**
136+
137+
.. code-block:: sh
138+
139+
FACTOR_CODER_DATA_FOLDER=/path/to/data/factor_implementation_source_data_all
140+
141+
- **Path to the folder containing partial private data (for debugging):**
142+
143+
.. code-block:: sh
144+
145+
FACTOR_CODER_DATA_FOLDER_DEBUG=/path/to/data/factor_implementation_source_data_debug
146+
147+
- **Maximum time (in seconds) for writing factor code:**
148+
149+
.. code-block:: sh
150+
151+
FACTOR_CODER_FILE_BASED_EXECUTION_TIMEOUT=300
152+
153+
- **Maximum number of factors to write in one experiment:**
154+
155+
.. code-block:: sh
156+
157+
FACTOR_CODER_SELECT_THRESHOLD=5
158+
159+
- **Number of developing loops for writing factors:**
160+
161+
.. code-block:: sh
162+
163+
FACTOR_CODER_MAX_LOOP=10
85164

docs/scens/data_copilot_fin.rst

Lines changed: 100 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,29 @@ Finance Data Copilot
55
=====================
66

77

8-
**Automated Quantitative Trading & Factors Extraction from Financial Reports📄**
8+
**🤖 Automated Quantitative Trading & Factors Extraction from Financial Reports**
99
---------------------------------------------------------------------------------
1010

11-
Background
12-
~~~~~~~~~~
11+
📖 Background
12+
~~~~~~~~~~~~~~
1313
**Research reports** are treasure troves of insights, often unveiling potential **factors** that can drive successful quantitative trading strategies.
1414
Yet, with the sheer volume of reports available, extracting the most valuable insights efficiently becomes a daunting task.
1515

1616
Furthermore, rather than hastily replicating factors from a report, it's essential to delve into the underlying logic of their construction.
1717
Does the factor capture the essential market dynamics? How unique is it compared to the factors already in your library?
1818

1919
Therefore, there is an urgent need for a systematic approach to design a framework that can effectively manage this process.
20-
This is where our R&D Agent comes into play.
20+
This is where our RDAgent comes into play.
21+
2122

23+
🎥 Demo
24+
~~~~~~~~~~
25+
TODO: Here should put a video of the demo.
2226

2327

24-
Introduction
25-
~~~~~~~~~~~~
26-
In this scenario, our agent demonstrates the process of extracting factors from financial research reports, implementing these factors, and analyzing their performance through Qlib backtesting.
28+
🌟 Introduction
29+
~~~~~~~~~~~~~~~~
30+
In this scenario, RDAgent demonstrates the process of extracting factors from financial research reports, implementing these factors, and analyzing their performance through Qlib backtesting.
2731
This process continually expands and refines the factor library.
2832

2933
Here's an enhanced outline of the steps:
@@ -45,7 +49,7 @@ Here's an enhanced outline of the steps:
4549
**Step 4 : Backtesting with Qlib 📉**
4650

4751
- Integrate the full dataset into the factor implementation code and prepare the factor library.
48-
- Perform backtesting using the Alpha158+ model in Qlib to assess the factor's effectiveness and performance.
52+
- Conduct backtesting using the Alpha158 plus newly developed factors and LGBModel in Qlib to evaluate the new factors' effectiveness and performance.
4953

5054
+----------------+------------+----------------+----------------------------------------------------+
5155
| Dataset | Model | Factors | Data Split |
@@ -59,29 +63,102 @@ Here's an enhanced outline of the steps:
5963
| | | | +-----------+--------------------------+ |
6064
+----------------+------------+----------------+----------------------------------------------------+
6165

62-
6366
**Step 5 : Feedback Analysis 🔍**
64-
- Analyze backtest results.
65-
- Incorporate feedback to refine hypotheses.
6667

67-
**Step 6 : Knowledge Base Refinement ♻️**
68-
- Refine the knowledge base based on feedback and repeat the process.
68+
- Analyze backtest results to assess performance.
69+
- Incorporate feedback to refine hypotheses and improve the model.
6970

70-
Demo
71-
~~~~~~~~~~
72-
.. TODO
71+
**Step 6 :Hypothesis Refinement ♻️**
7372

74-
Scen2 Quick Start
73+
- Refine hypotheses based on feedback from backtesting.
74+
- Repeat the process to continuously improve the model.
75+
76+
⚡ Quick Start
7577
~~~~~~~~~~~~~~~~~
7678

77-
To quickly start the factor extraction process, run the following command in your terminal within the `rdagent` virtual environment:
79+
You can try our demo by running the following command:
7880

79-
.. code-block:: sh
81+
- 🐍 Create a Conda Environment
82+
- Create a new conda environment with Python (3.10 and 3.11 are well tested in our CI):
83+
84+
.. code-block:: sh
85+
86+
conda create -n rdagent python=3.10
8087
81-
python rdagent/app/qlib_rd_loop/factor_from_report_w_sc.py.py
88+
- Activate the environment:
8289

90+
.. code-block:: sh
8391
84-
Usage of modules
85-
~~~~~~~~~~~~~~~~~
86-
TODO: Show some examples:
92+
conda activate rdagent
93+
94+
- 🛠️ Run Make Files
95+
- Navigate to the directory containing the MakeFile and set up the development environment:
96+
97+
.. code-block:: sh
98+
99+
make dev
100+
101+
- 📦 Install Pytorch
102+
- Install Pytorch and related libraries:
103+
104+
.. code-block:: sh
105+
106+
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
107+
pip3 install torch_geometric
108+
109+
- ⚙️ Environment Configuration
110+
- Place the `.env` file in the same directory as the `.env.example` file.
111+
- The `.env.example` file contains the environment variables required for users using the OpenAI API (Please note that `.env.example` is an example file. `.env` is the one that will be finally used.)
112+
113+
- Export each variable in the .env file:
114+
115+
.. code-block:: sh
116+
117+
export $(grep -v '^#' .env | xargs)
118+
119+
- If you want to change the default environment variables, you can refer to `Env Config`_ below
120+
121+
- 🚀 Run the Application
122+
.. code-block:: sh
123+
124+
python rdagent/app/qlib_rd_loop/factor_from_report_w_sc.py
125+
126+
127+
128+
🛠️ Usage of modules
129+
~~~~~~~~~~~~~~~~~~~~~
130+
131+
.. _Env Config:
132+
133+
- **Env Config**
134+
135+
The following environment variables can be set in the `.env` file to customize the application's behavior:
136+
- **Path to the folder containing research reports:**
137+
138+
.. code-block:: sh
139+
140+
QLIB_FACTOR_LOCAL_REPORT_PATH=/path/to/research/reports
141+
142+
- **Path to the JSON file listing research reports for factor extraction:**
143+
144+
.. code-block:: sh
145+
146+
QLIB_FACTOR_REPORT_RESULT_JSON_FILE_PATH=/path/to/reports/list.json
147+
148+
- **Maximum time (in seconds) for writing factor code:**
149+
150+
.. code-block:: sh
151+
152+
FACTOR_CODER_FILE_BASED_EXECUTION_TIMEOUT=300
153+
154+
- **Maximum number of factors to write in one experiment:**
155+
156+
.. code-block:: sh
157+
158+
FACTOR_CODER_SELECT_THRESHOLD=5
159+
160+
- **Number of developing loops for writing factors:**
161+
162+
.. code-block:: sh
87163
164+
FACTOR_CODER_MAX_LOOP=10

0 commit comments

Comments
 (0)