Skip to content

Commit

Permalink
doc: Improved documentation for two factor scenarios. (#172)
Browse files Browse the repository at this point in the history
* Fixed some bugs introduced during refactoring.

* Improved documentation for two factor scenarios.

* Update factor_from_report_w_sc.py

* Improved some details.
  • Loading branch information
WinstonLiyt authored Aug 6, 2024
1 parent e767005 commit 610abe3
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 57 deletions.
93 changes: 65 additions & 28 deletions docs/scens/data_agent_fin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,79 @@
Finance Data Agent
=====================

Scen1
-----
🤖 Knowledge-Based Hypothesis Generation and Iteration

Scen1 Intro
~~~~~~~~~~~
In this scenario, our model autonomously generates and tests hypotheses using a knowledge base. The process involves:

- **🔍 Hypothesis Generation**: The model proposes new hypotheses.
- **📝 Factor Creation**: Write and define new factors.
- **✅ Factor Validation**: Validate the factors quantitatively.
- **📈 Backtesting with Qlib**:

- **Dataset**: CSI300
- **Model**: LGBModel
- **Factors**: Alpha158 +
- **Data Split**:

- **Train**: 2008-01-01 to 2014-12-31
- **Valid**: 2015-01-01 to 2016-12-31
- **Test**: 2017-01-01 to 2020-08-01
- **🔄 Feedback Analysis**: Analyze backtest results.
- **🔧 Hypothesis Refinement**: Refine hypotheses based on feedback and repeat.

Scen1 Demo

**Automated Quantitative Trading & Iterative Factors Evolution 🤖**
-------------------------------------------------------------------

Background
~~~~~~~~~~
In the dynamic world of quantitative trading, **factors** are the secret weapons that traders use to harness market inefficiencies.

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.
By tapping into this rich vein of data, quantitative traders craft sophisticated strategies that not only capitalize on market patterns but also drastically enhance trading efficiency and accuracy.

Embrace the power of factors, and you're not just trading; you're strategically outsmarting the market.


Introduction
~~~~~~~~~~~~
In this scenario, our agent illustrates the iterative process of hypothesis generation, knowledge construction, and decision-making.

It highlights how financial factors evolve through continuous feedback and refinement.

Here's an enhanced outline of the steps:

**Step 1 : Hypothesis Generation 🔍**

- Generate and propose initial hypotheses based on previous experiment analysis and domain expertise, with thorough reasoning and financial justification.

**Step 2 : Factor Creation ✨**

- Based on the hypothesis, divide the tasks.
- Each task involves developing, defining, and implementing a new financial factor, including its name, description, formulation, and variables.

**Step 3 : Factor Implementation 👨‍💻**

- Implement the factor code based on the description, evolving it as a developer would.
- Quantitatively validate the newly created factors.

**Step 4 : Backtesting with Qlib 📉**

- Integrate the full dataset into the factor implementation code and prepare the factor library.
- Perform backtesting using the Alpha158+ model in Qlib to assess the factor's effectiveness and performance.

+----------------+------------+----------------+----------------------------------------------------+
| Dataset | Model | Factors | Data Split |
+================+============+================+====================================================+
| CSI300 | LGBModel | Alpha158 Plus | +-----------+--------------------------+ |
| | | | | Train | 2008-01-01 to 2014-12-31 | |
| | | | +-----------+--------------------------+ |
| | | | | Valid | 2015-01-01 to 2016-12-31 | |
| | | | +-----------+--------------------------+ |
| | | | | Test | 2017-01-01 to 2020-08-01 | |
| | | | +-----------+--------------------------+ |
+----------------+------------+----------------+----------------------------------------------------+


**Step 5 : Feedback Analysis 🔍**
- Analyze backtest results.
- Incorporate feedback to refine hypotheses.

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

Demo
~~~~~~~~~~
.. TODO
Scen1 Quick Start
Quick Start
~~~~~~~~~~~~~~~~~

To quickly start the factor extraction process, run the following command in your terminal within the 'rdagent' virtual environment:
To quickly start the Automated Quantitative Trading & Iterative Factors Evolution process, run the following command in your terminal within the `rdagent` virtual environment:

.. code-block:: sh
python rdagent/app/qlib_rd_loop/factor.py
python rdagent/app/qlib_rd_loop/factor_w_sc.py
Usage of modules
Expand Down
92 changes: 65 additions & 27 deletions docs/scens/data_copilot_fin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,80 @@ Finance Data Copilot
=====================


Scen2:
------
📄 Research Report-Based Factor Extraction

Scen2 Intro
~~~~~~~~~~~
In this scenario, factors and hypotheses are extracted from research reports. The process includes:

- **🔍 Factor Extraction**: Extract relevant factors from research reports.
- **📝 Factor Creation**: Define these extracted factors.
- **✅ Factor Validation**: Validate the extracted factors.
- **📈 Backtesting with Qlib**:

- **Dataset**: CSI300
- **Model**: LGBModel
- **Factors**: Alpha158 +
- **Data Split**:

- **Train**: 2008-01-01 to 2014-12-31
- **Valid**: 2015-01-01 to 2016-12-31
- **Test**: 2017-01-01 to 2020-08-01
- **🔄 Feedback Analysis**: Analyze backtest results.
- **🔧 Hypothesis Refinement**: Refine hypotheses based on feedback and continue the cycle.

Scen2 Demo
**Automated Quantitative Trading & Factors Extraction from Financial Reports📄**
---------------------------------------------------------------------------------

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

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

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



Introduction
~~~~~~~~~~~~
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.
This process continually expands and refines the factor library.

Here's an enhanced outline of the steps:

**Step 1 : Hypothesis Generation 🔍**

- Generate and propose initial hypotheses based on insights from financial reports with thorough reasoning and financial justification.

**Step 2 : Factor Creation ✨**

- Based on the hypothesis and financial reports, divide the tasks.
- Each task involves developing, defining, and implementing a new financial factor, including its name, description, formulation, and variables.

**Step 3 : Factor Implementation 👨‍💻**

- Implement the factor code based on the description, evolving it as a developer would.
- Quantitatively validate the newly created factors.

**Step 4 : Backtesting with Qlib 📉**

- Integrate the full dataset into the factor implementation code and prepare the factor library.
- Perform backtesting using the Alpha158+ model in Qlib to assess the factor's effectiveness and performance.

+----------------+------------+----------------+----------------------------------------------------+
| Dataset | Model | Factors | Data Split |
+================+============+================+====================================================+
| CSI300 | LGBModel | Alpha158 Plus | +-----------+--------------------------+ |
| | | | | Train | 2008-01-01 to 2014-12-31 | |
| | | | +-----------+--------------------------+ |
| | | | | Valid | 2015-01-01 to 2016-12-31 | |
| | | | +-----------+--------------------------+ |
| | | | | Test | 2017-01-01 to 2020-08-01 | |
| | | | +-----------+--------------------------+ |
+----------------+------------+----------------+----------------------------------------------------+


**Step 5 : Feedback Analysis 🔍**
- Analyze backtest results.
- Incorporate feedback to refine hypotheses.

**Step 6 : Knowledge Base Refinement ♻️**
- Refine the knowledge base based on feedback and repeat the process.

Demo
~~~~~~~~~~
.. TODO
Scen2 Quick Start
~~~~~~~~~~~~~~~~~

To quickly start the factor extraction process, run the following command in your terminal within the 'rdagent' virtual environment:
To quickly start the factor extraction process, run the following command in your terminal within the `rdagent` virtual environment:

.. code-block:: sh
python rdagent/app/qlib_rd_loop/factor_from_report_sh.py
python rdagent/app/qlib_rd_loop/factor_from_report_w_sc.py.py
Usage of modules
Expand Down
2 changes: 1 addition & 1 deletion rdagent/scenarios/qlib/experiment/factor_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def simulator(self) -> str:
@property
def rich_style_description(self) -> str:
return """
### R&D Agent-Qlib: Automated Quantitative Trading & Iterative Factor Evolution Demo
### R&D Agent-Qlib: Automated Quantitative Trading & Iterative Factors Evolution Demo
#### [Overview](#_summary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class QlibFactorFromReportScenario(QlibFactorScenario):
@property
def rich_style_description(self) -> str:
return """
### R&D Agent-Qlib: Automated Quantitative Trading & Factor Extraction from Financial Reports Demo
### R&D Agent-Qlib: Automated Quantitative Trading & Factors Extraction from Financial Reports Demo
#### [Overview](#_summary)
Expand Down

0 comments on commit 610abe3

Please sign in to comment.