Skip to content

Commit

Permalink
docs: Added documentation for Qlib Factor Loop, Qlib Model Loop, Data…
Browse files Browse the repository at this point in the history
…-Copilot, and Paper-Copilot scenario. (#178)

* Fixed some bugs introduced during refactoring.

* Added docs for four scenrios.

* Update factor_from_report_w_sc.py
  • Loading branch information
WinstonLiyt authored Aug 8, 2024
1 parent b7aebf8 commit 9683d1f
Show file tree
Hide file tree
Showing 5 changed files with 370 additions and 106 deletions.
117 changes: 98 additions & 19 deletions docs/scens/data_agent_fin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Finance Data Agent
=====================


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

Background
~~~~~~~~~~
📖 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.
Expand All @@ -18,8 +18,13 @@ By tapping into this rich vein of data, quantitative traders craft sophisticated
Embrace the power of factors, and you're not just trading; you're strategically outsmarting the market.


Introduction
~~~~~~~~~~~~
🎥 Demo
~~~~~~~~~~
TODO: Here should put a video of the demo.


🌟 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.
Expand All @@ -43,7 +48,7 @@ Here's an enhanced outline of the steps:
**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.
- Conduct backtesting using the Alpha158 plus newly developed factors and LGBModel in Qlib to evaluate the new factors' effectiveness and performance.

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


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

- Analyze backtest results to assess performance.
- Incorporate feedback to refine hypotheses and improve the model.

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

Demo
~~~~~~~~~~
.. TODO
- Refine hypotheses based on feedback from backtesting.
- Repeat the process to continuously improve the model.

Quick Start
Quick Start
~~~~~~~~~~~~~~~~~

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

.. code-block:: sh
- 🐍 Create a Conda Environment
- Create a new conda environment with Python (3.10 and 3.11 are well tested in our CI):

.. code-block:: sh
conda create -n rdagent python=3.10
python rdagent/app/qlib_rd_loop/factor_w_sc.py
- Activate the environment:

.. code-block:: sh
Usage of modules
~~~~~~~~~~~~~~~~~
TODO: Show some examples:
conda activate rdagent
- 🛠️ Run Make Files
- Navigate to the directory containing the MakeFile and set up the development environment:

.. code-block:: sh
make dev
- 📦 Install Pytorch
- Install Pytorch and related libraries:

.. code-block:: sh
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip3 install torch_geometric
- ⚙️ Environment Configuration
- Place the `.env` file in the same directory as the `.env.example` file.
- 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.)

- Export each variable in the .env file:

.. code-block:: sh
export $(grep -v '^#' .env | xargs)
- If you want to change the default environment variables, you can refer to `Env Config`_ below

- 🚀 Run the Application
.. code-block:: sh
python rdagent/app/qlib_rd_loop/factor_w_sc.py
🛠️ Usage of modules
~~~~~~~~~~~~~~~~~~~~~

.. _Env Config:

- **Env Config**

The following environment variables can be set in the `.env` file to customize the application's behavior:
- **Path to the folder containing private data (default fundamental data in Qlib):**

.. code-block:: sh
FACTOR_CODER_DATA_FOLDER=/path/to/data/factor_implementation_source_data_all
- **Path to the folder containing partial private data (for debugging):**

.. code-block:: sh
FACTOR_CODER_DATA_FOLDER_DEBUG=/path/to/data/factor_implementation_source_data_debug
- **Maximum time (in seconds) for writing factor code:**

.. code-block:: sh
FACTOR_CODER_FILE_BASED_EXECUTION_TIMEOUT=300
- **Maximum number of factors to write in one experiment:**

.. code-block:: sh
FACTOR_CODER_SELECT_THRESHOLD=5
- **Number of developing loops for writing factors:**

.. code-block:: sh
FACTOR_CODER_MAX_LOOP=10
123 changes: 100 additions & 23 deletions docs/scens/data_copilot_fin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,29 @@ Finance Data Copilot
=====================


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

Background
~~~~~~~~~~
📖 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.
This is where our RDAgent comes into play.


🎥 Demo
~~~~~~~~~~
TODO: Here should put a video of the demo.


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.
🌟 Introduction
~~~~~~~~~~~~~~~~
In this scenario, RDAgent 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:
Expand All @@ -45,7 +49,7 @@ Here's an enhanced outline of the steps:
**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.
- Conduct backtesting using the Alpha158 plus newly developed factors and LGBModel in Qlib to evaluate the new factors' effectiveness and performance.

+----------------+------------+----------------+----------------------------------------------------+
| Dataset | Model | Factors | Data Split |
Expand All @@ -59,29 +63,102 @@ Here's an enhanced outline of the steps:
| | | | +-----------+--------------------------+ |
+----------------+------------+----------------+----------------------------------------------------+


**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.
- Analyze backtest results to assess performance.
- Incorporate feedback to refine hypotheses and improve the model.

Demo
~~~~~~~~~~
.. TODO
**Step 6 :Hypothesis Refinement ♻️**

Scen2 Quick Start
- Refine hypotheses based on feedback from backtesting.
- Repeat the process to continuously improve the model.

⚡ Quick Start
~~~~~~~~~~~~~~~~~

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

.. code-block:: sh
- 🐍 Create a Conda Environment
- Create a new conda environment with Python (3.10 and 3.11 are well tested in our CI):

.. code-block:: sh
conda create -n rdagent python=3.10
python rdagent/app/qlib_rd_loop/factor_from_report_w_sc.py.py
- Activate the environment:

.. code-block:: sh
Usage of modules
~~~~~~~~~~~~~~~~~
TODO: Show some examples:
conda activate rdagent
- 🛠️ Run Make Files
- Navigate to the directory containing the MakeFile and set up the development environment:

.. code-block:: sh
make dev
- 📦 Install Pytorch
- Install Pytorch and related libraries:

.. code-block:: sh
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip3 install torch_geometric
- ⚙️ Environment Configuration
- Place the `.env` file in the same directory as the `.env.example` file.
- 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.)

- Export each variable in the .env file:

.. code-block:: sh
export $(grep -v '^#' .env | xargs)
- If you want to change the default environment variables, you can refer to `Env Config`_ below

- 🚀 Run the Application
.. code-block:: sh
python rdagent/app/qlib_rd_loop/factor_from_report_w_sc.py
🛠️ Usage of modules
~~~~~~~~~~~~~~~~~~~~~

.. _Env Config:

- **Env Config**

The following environment variables can be set in the `.env` file to customize the application's behavior:
- **Path to the folder containing research reports:**

.. code-block:: sh
QLIB_FACTOR_LOCAL_REPORT_PATH=/path/to/research/reports
- **Path to the JSON file listing research reports for factor extraction:**

.. code-block:: sh
QLIB_FACTOR_REPORT_RESULT_JSON_FILE_PATH=/path/to/reports/list.json
- **Maximum time (in seconds) for writing factor code:**

.. code-block:: sh
FACTOR_CODER_FILE_BASED_EXECUTION_TIMEOUT=300
- **Maximum number of factors to write in one experiment:**

.. code-block:: sh
FACTOR_CODER_SELECT_THRESHOLD=5
- **Number of developing loops for writing factors:**

.. code-block:: sh
FACTOR_CODER_MAX_LOOP=10
Loading

0 comments on commit 9683d1f

Please sign in to comment.