AI Personal Learning
and practical guidance
讯飞绘镜

Abu quantitative trading system: Python based open source quantitative trading platform

General Introduction

Abu Quantitative Trading System is an open source platform based on Python. It was created by user "bbfamily" to help investors realize quantitative trading strategies through code. The system supports backtesting and trading of a wide range of financial products such as stocks, options, futures and bitcoin. It incorporates machine learning technology to provide data analysis and strategy optimization. As of March 25, 2025, this project has over 12k stars and 3.8k forks on GitHub, showing a high community following. Abu's goal is to make investment decisions easier for users through automation and intelligence.

阿布量化交易系统:基于Python的开源量化交易平台-1


 

Function List

  • Supports multi-market trading: it can handle quotes data from Shanghai and Shenzhen stock markets, U.S. stocks, futures and digital currencies.
  • Backtest function: Provides historical data analysis to test the effectiveness of trading strategies.
  • Stock Picking and Timing: Built-in multiple stock picking and timing strategies for users to screen stocks and decide when to buy and sell.
  • Machine Learning Integration: Combine machine learning algorithms to optimize trading models.
  • Highly customizable: users can modify the code and adjust the strategies and parameters according to their needs.
  • Data management: support the collection and parallel processing of financial time series data.
  • Trade execution: Connect to market interfaces to automate buy and sell operations.

 

Using Help

The Abu Quantitative Trading System is an open source project and users need some basic programming skills to get started. It does not have an off-the-shelf graphical interface, but runs through Python code. Below are the detailed installation and usage steps:

Installation process

  1. Preparing the environment
    • Ensure that your computer has Python 3.x installed (3.7 or above recommended).
    • Download and install the Git tool for pulling code from GitHub.
    • Optional: Install Anaconda for easy management of the Python environment and dependent packages.
  2. Cloning Code
    • Open a terminal or command line and enter the following command to pull the Abu project:
      git clone https://github.com/bbfamily/abu.git
      
    • When finished, go to the project folder:
      cd abu
      
  3. Installation of dependencies
    • The project requires some Python library support, which is installed by running the following command in the terminal:
      pip install -r requirements.txt
      
    • If you don't have a file, you can install the core libraries manually, for examplenumpy,pandascap (a poem)sklearn::
      pip install numpy pandas scikit-learn
      
  4. Verify Installation
    • In the terminal, typepython, enter the Python environment.
    • (of a computer) runimport abupy, if no error is reported, the installation was successful.

Usage

The core of the Abu system is to run quantitative trading strategies through code. Below is the detailed operational flow of the main functions:

1. Data collection and preparation

  • Abu supports getting historical data from multiple markets, such as Shanghai and Shenzhen stock markets or US stocks.
  • Set the market type in the code, for example:
    from abupy import ABuEnv
    ABuEnv.g_market_target = 'us'  # 设置为美股市场
    

  • Run the data collection function:
    from abupy import all_symbol
    symbols = all_symbol()  # 获取所有股票代码
    

2. Backtesting trading strategies

  • Define buy and sell strategies. For example, use a breakout strategy:
    buy_factors = [{'xd': 60, 'class': 'AbuFactorBuyBreak'}]
    sell_factors = [{'stop_loss_n': 0.5, 'class': 'AbuFactorAtrNStop'}]
    
  • Set the initial funding and backtesting time:
    from abupy import run_loop_back
    result = run_loop_back(
    read_cash=1000000,  # 初始资金100万
    buy_factors=buy_factors,
    sell_factors=sell_factors,
    n_folds=2,  # 回测2年数据
    start='2023-01-01',  # 开始时间
    end='2025-01-01'  # 结束时间
    )
    
  • View Results: After running, the system will return trade profit/loss and statistics.

3. Stock selection and timing

  • Use the built-in stock picker to screen stocks. For example, screen by price:
    from abupy import AbuPickStockPriceMinMax
    stock_picks = [{'class': 'AbuPickStockPriceMinMax', 'threshold_price_min': 50.0}]
    
  • Combined with backtesting runs:
    result = run_loop_back(read_cash=1000000, buy_factors=buy_factors, sell_factors=sell_factors, stock_picks=stock_picks)
    

4. Machine learning optimization

  • Abu integrates machine learning capabilities to optimize strategy parameters. Example:
    from abupy import AbuMLGrid
    best_params = AbuMLGrid.grid_search_mul_init_kwargs(...)  # 优化参数
    
  • Apply the optimized parameters to the backtest.

5. Operation and commissioning

  • Save the code as.pyfiles, such astrade.pyThe
  • Runs in the terminal:
    python trade.py
    
  • If something goes wrong, check the log output and adjust the code or parameters.

Featured Function Operation

  • Multi-market support: ByABuEnv.g_market_targetSwitching markets, such as'cn'(SHANGHAI),'us'(U.S. stocks) or'btc'(Bitcoin).
  • parallel processing: Settingsn_process_klcap (a poem)n_process_pickparameters, utilizing multi-core CPUs to accelerate data processing and backtesting.
  • Customized Strategies: Users can write their own buy-sell logic to put into thebuy_factorsmaybesell_factorsThe

More tutorials can be found in the folder in the project, which contains detailed IPython Notebook documentation.

 

application scenario

  1. Individual quantitative investments
    Individual investors can use Abu to test their trading ideas, such as verifying that a breakout strategy is profitable through historical data.
  2. Financial Research
    Researchers can use it to analyze market trends and mine data patterns in conjunction with machine learning.
  3. Automated trading
    Programmers can connect to real-time data interfaces for fully automated buying and selling operations.

 

QA

  1. Which markets does Abu support?
    It supports a wide range of markets such as Shanghai and Shenzhen stock markets, US stocks, futures and Bitcoin, and users can switch freely.
  2. Need a programming foundation?
    Yes, Abu runs on Python and requires the user to be able to write simple code.
  3. How do I get help?
    You can check out the file on GitHub or follow the tutorial on WeChat "abu_quant".
May not be reproduced without permission:Chief AI Sharing Circle " Abu quantitative trading system: Python based open source quantitative trading platform
en_USEnglish