Python Quantitative Trading: Strategy Creation and Operation Process

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 strategies440e5fd1b932473dab27ad18956a05d1.png

 1.2 Strategy interface6a298e8488bf4ddab4f185ce3105b084.png

 2. Introduction to the function and operation of the strategy interfacedce402eab8724e12821d6ad4b373ca4a.png

 

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:6e609b5b87f848e89840b7e9da67e7db.png

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.6dcf5c80790d4eca85c07d81eb48c95b.png

 

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

 

Guess you like

Origin blog.csdn.net/2301_76571514/article/details/130981234