learning target
- Target
- Know how to create and run strategies
- Know the relevant settings of the policy
- Know the strategy operation process of RQ
- application
- none
1. Experience creating strategies and running the strategy process
1.1 Creating strategies
1.2 Strategy interface
2. Introduction to the function and operation of the strategy interface
2.1 What a complete strategy needs to do
- Select the running information of the strategy:
- Choose the operating range and initial funds
- Select backtest frequency
- Select stock pool
- Write the logic of the strategy
- Obtain stock quotes and fundamental data
- Which stocks to choose and when to trade
- analysis results
- Strategy Indicator Analysis
2.2 Introduction to Initial Policy Settings
- Basic settings: specify the start and end dates of backtesting , initial funding , and backtesting frequency
- Start and end dates: the time interval for the strategy to run
- Initial capital: the total capital invested
- Frequency of backtesting: There are two options, daily backtesting/minute backtesting. Just do stock quantitative selection day backtesting
- advanced settings:
Regarding the other parts of the advanced settings, when introducing the transaction function, introduce
2.3 Analysis of the operation process of the strategy body
- Implement policy initialization logic in the init method
- The stock pool of the strategy: make trading judgments in those stocks (for example: HS300)
- You can choose to perform some operations before the daily opening in before_trading , such as obtaining historical market data for some data preprocessing, obtaining current account funds , etc.
- Implement the specific logic of the strategy in the handle_bar method, including the generation of trading signals and the creation of orders . The logic in handle_bar will be triggered every time the bar data is updated.
The sequence of calls is:
- 1、init
- 2、before_trading
- 3、handle_bar
2.4 Analysis of strategy results
After the backtest is completed, the position, profit and loss, transaction, risk and other information of the backtest will be displayed on the 'Backtest Results' page