Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/letianzj/quanttrader

Backtest and live trading in Python
https://github.com/letianzj/quanttrader

algo-trading algorithmic-trading algotrading backtesting-trading-strategies backtests interval-strategy quant-trader quant-trading quantitative-trading stock trading-algorithms trading-platform trading-strategies trading-systems

Last synced: 1 day ago
JSON representation

Backtest and live trading in Python

Awesome Lists containing this project

README

        

# quanttrader
[![pypi](https://img.shields.io/pypi/v/nseazy.svg)](https://pypi.python.org/pypi/quanttrader)
[![python](https://img.shields.io/pypi/pyversions/nseazy.svg)](https://pypi.python.org/pypi/quanttrader)
[![License Apache 2.0](https://badgen.net/badge/license/apache2.0/blue)](https://opensource.org/licenses/MIT)

Welcome to quanttrader, a pure python-based event-driven backtest and live trading package for quant traders.

The source code is completely open-sourced [here on GitHub](https://github.com/letianzj/quanttrader). The package is published [here on pypi](https://pypi.org/project/quanttrader/) and is ready to be pip installed. The document is hosted [here on readthedocs](https://quanttrader.readthedocs.io/).

In most cases, a backtest strategy can be directly used for live trade by simply switching to live brokerage. A control window is provided to monitor live trading sessions for each strategy separately and the portfolio as a whole.

### Backtest

[Backtest code structure](https://letianzj.github.io/quanttrading-backtest.html)

[Backtests examples](https://github.com/letianzj/QuantResearch/tree/master/backtest)

[Reinforcement trader](https://github.com/letianzj/QuantResearch/blob/master/ml/reinforcement_trader.ipynb)

### Live trading

[Live Trading demo video](https://youtu.be/CrsrTxqiXNY)

[Live Trading code structure](https://letianzj.github.io/live-trading-ib-native-python.html)

__Prerequisite__: download and install IB TWS or IB Gateway; enable API connection as described [here](https://interactivebrokers.github.io/tws-api/initial_setup.html).

__Installation__

Step 1

```shell
pip install quanttrader
```

Alternatively, download or git the source code and include unzipped path in PYTHONPATH environment variable.

step 2

Download [live_engine.py](https://github.com/letianzj/quanttrader/blob/master/examples/live_engine.py), [config_live.yaml](https://github.com/letianzj/quanttrader/blob/master/examples/config_live.yaml), [order_per_interval_strategy.py](order_per_interval_strategy.py) by clicking Raw button, right clicking save as, and then change the file extension to .py or .yaml.

step 3
```shell
cd where_the_files_are_saved
python live_engine.py
```

__Instruments Supported and Example__

* __Stock__: AMZN STK SMART
* __Foreign Exchange__: EURGBP CASH IDEALPRO
* __Futures__: ESM9 FUT GLOBEX
* __Options on Stock__: AAPL OPT 20201016 128.75 C SMART
* __Options on Futures__: ES FOP 20200911 3450 C 50 GLOBEX
* __Comdty__: XAUUSD CMDTY SMART

__Order Type Supported__

Basic order types. See [IB Doc](http://interactivebrokers.github.io/tws-api/basic_orders.html) for details.
* Auction
* Auction Limit
* Market
* Market If Touched
* Market On Close
* Market On Open
* Market to Limit
* Limit Order
* Limit if Touched
* Limit on Close
* Limit on Open
* Stop
* Stop Limit
* Trailing Stop
* Trailing Stop Limit

![gui](https://github.com/letianzj/quanttrader/blob/master/examples/gui.png)

**DISCLAIMER**
Open source, free to use, free to contribute, use at own risk. No promise of future profits nor responsibility of future loses.