Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
A Light Event-Driven Algorithmic Trading Engine
| Date | Stars |
|---|---|
| 2026-07-24 | 547 |
| 2026-07-25 | 547 |
| 2026-07-28 | 547 |
| 2026-07-30 | 547 |
| 2026-08-06 | 547 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# QTrader: A Light Event-Driven Algorithmic Trading Engine
<p align="center">
<img src ="https://img.shields.io/badge/version-0.1.0-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/platform-windows|linux|macos-yellow.svg"/>
<img src ="https://img.shields.io/badge/python-3.8|3.9|3.10-blue.svg" />
<img src ="https://img.shields.io/github/workflow/status/vnpy/vnpy/Python%20application/master"/>
<img src ="https://img.shields.io/badge/license-JXW-orange"/>
</p>
**Latest update on 2022-09-07**
## Key modifications
- 2022-09-07: Moved `qtrader.config` to `qtrader_config`
## Introduction
QTrader is a light and flexible event-driven algorithmic trading engine that
can be used to backtest strategies, and seamlessly switch to live trading
without any pain.
## Key Features
* Completely **same code** for backtesting / simulation / live trading
* Support trading of various assets: equity, futures
* Resourceful functionalities to support live monitoring and analysis
## Quick Install
You may run the folllowing command to install QTrader immediately:
```python
# Virtual environment is recommended (python 3.8 or above is supported)
>> conda create -n qtrader python=3.8
>> conda activate qtrader
# Install stable version from pip (currently version 0.0.4)
>> pip install qtrader
# Alternatively, install latest version from github
>> pip install git+https://github.com/josephchenhk/qtrader@master
```
## Create a Configuration File
At your current working directory, create `qtrader_config.py` if not exists.
There is an example `qtrader_config_sample.py` for your reference. Adjust the
items if necessary.
## Prepare the Data
QTrader supports bar data at the moment. What you need to do is creating a
folder with the name of the security you are interested in. Let's say you want
to backtest or trade HK equity **"HK.01157"** in frequency of **1 minute**, your
data folder should be like this (where "K_1M" stands for 1 minute; you can also
find a sample from the qtrader/examples/data):

And you can prepare OHLCV data in CSV format, with dates as their file names,
e.g., **"yyyy-mm-dd.csv"**:

Inside each csv file, the data columns should look like this:

Now you can specify the path of data folder in
<del>`qtrader/config/config.py`</del>
`qtrader_config.py`. For example, set
```python
DATA_PATH = {
"kline": "path_to_your_qtrader_folder/examples/data/k_line",
}
```
## Implement a Strategy
To implement a strategy is simple in QTrader. A strategy needs to implement
`init_strategy` and `on_bar` methods in `BaseStrategy`. Here is a quick sample:
```python
from qtrader.core.strategy import BaseStrategy
class MyStrategy(BaseStrategy):
def init_strategy(self):
pass
def on_bar(self, cur_data:Dict[str, Dict[Security, Bar]]):
print(cur_data)
```
## Record Variables
QTrader provides a module named `BarEventEngineRecorder` to record variables
during backtesting and/or trading. By default it saves `datetime`,
`portfolio_value` and `action` at every time step.
If you want to record additional variables (let's say it is called `var`), you
need to write a method called `get_var` in your strategy:
```python
from qtrader.core.strategy import BaseStrategy
class MyStrategy(BaseStrategy):
def get_var(self):
return var
```
And initialize your `BarEventEngineRecorder` with the same vairable `var=[]`(if
you want to record every timestep) or `var=None`(if you want to record only the
last updated value):
```python
recorder = BarEventEngineRecorder(var=[])
```
## Run a Backtest
Now wExcerpt of 8,671 characters
Read on GitHub314
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:1cbbf9700fd5f536, topic:trading