Maintained

RQAlpha guide

RQAlpha is a standard backtester for Chinese equity quants, with an architecture designed for extension.

Last reviewed

Quick answer

RQAlpha is Ricequant’s open-source Python framework for backtesting and simulated trading of China A-shares and futures. Strategies implement init, before_trading and handle_bar, and a mod system plugs in data sources, risk checks and brokers. Commercial use requires a license from Ricequant.

RQAlpha at a glance

Category
Backtest + live trading engines
Language
Python
License
Apache-2.0 (non-commercial terms apply)
Does
Backtesting, Paper trading
Markets
Stocks, Futures
Best for
China A-share and futures research.
In AlgoGP
Use the exported strategy object from your own code

Pick it if

China A-share and futures research.

Watch out for

Chinese-language community.

RQAlpha strengths and limitations

Strengths

  • Mod system for data, brokers and analysers.
  • A-share trading rules (T+1, price limits) modelled.

Limitations

  • Chinese-language community.
  • Non-commercial license terms.

RQAlpha example

pip install rqalpha
Install
from rqalpha.apis import order_shares

def init(context):
    context.s1 = "000001.XSHE"

def handle_bar(context, bar_dict):
    if not context.portfolio.positions[context.s1].quantity:
        order_shares(context.s1, 1000)
Buy a stock on the first bar.

Use RQAlpha with AlgoGP

AlgoGP does not add RQAlpha to projects automatically yet, but nothing stops you using them together. Every AlgoGP project exports plain Python with a framework-neutral strategy object, so you can call it from RQAlpha yourself.

  1. 1

    Design and backtest in AlgoGP

    Describe the idea to the copilot and backtest it on AlgoGP’s normalized history.

  2. 2

    Add any bridge to get the adapter core

    Adding a bridged framework (for example Backtrader) writes frameworks/algogp_bridge.py, whose StrategyBridge.on_bar() returns the orders the strategy wants.

  3. 3

    Call it from RQAlpha

    Feed RQAlpha’s bars to StrategyBridge, place the returned orders with RQAlpha, and report fills back with sync().

RQAlpha: frequently asked questions

Can RQAlpha be used commercially?

Commercial use needs a license from Ricequant; check the repository’s license file.

RQAlpha alternatives

Independent guide. AlgoGP is not affiliated with RQAlpha. Features, licenses and maintenance change; check the official documentation. Nothing here is investment advice.

Build a strategy