1. Data collection and loading. A-share data is obtained by tushare. Because frequent acquisition of multiple stocks is prone to interface errors, a stock database can be established locally.
2. Using a simple momentum+trend tracking strategy, the idea is to calculate and sort the earnings of 24 stocks in the past 30 days, select the first 10 stocks to join the stock selection pool (momentum), and roll the calculation and judgment day by day: if a stock in the stock selection pool meets the 20-day moving average and has no position, it will be bought (tracking the trend with the 20-day moving average as the lifeline). If a stock has held a position, but it is judged that it is not in the stock selection pool or the stock price is below the 20 moving average, it will be sold. Each transaction is based on the average position of ten stocks.
3. Write another cycle to traverse the data of 24 stocks and load it into the post-test system. The initial principal is set at 6,543,800 yuan, and the handling fee is one thousandth. After the back test, print out the transaction diary.