BackTesting Engine - A feature-rich Python framework for backtesting and trading
Project description
nijigen-backtrader
A fork of backtrader - Live Trading and backtesting platform written in Python.
Quick Start
Here's a snippet of a Simple Moving Average CrossOver. It can be done in several different ways. Use the docs (and examples) Luke!
from datetime import datetime
import backtrader as bt
class SmaCross(bt.SignalStrategy):
def __init__(self):
sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)
crossover = bt.ind.CrossOver(sma1, sma2)
self.signal_add(bt.SIGNAL_LONG, crossover)
cerebro = bt.Cerebro()
cerebro.addstrategy(SmaCross)
data0 = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1),
todate=datetime(2012, 12, 31))
cerebro.adddata(data0)
cerebro.run()
cerebro.plot()
Features
-
Live Data Feed and Trading with:
- Interactive Brokers (needs
IbPyand benefits greatly from an installedpytz) - Visual Chart (needs a fork of
comtypes) - Oanda (needs
oandapy) (REST API Only)
- Interactive Brokers (needs
-
Data feeds from csv/files, online sources or from pandas and blaze
-
Filters for datas, like breaking a daily bar into chunks to simulate intraday or working with Renko bricks
-
Multiple data feeds and multiple strategies supported
-
Multiple timeframes at once
-
Integrated Resampling and Replaying
-
Step by Step backtesting or at once
-
Integrated battery of indicators
-
TA-Lib indicator support (needs python ta-lib)
-
Easy development of custom indicators
-
Analyzers (e.g., TimeReturn, Sharpe Ratio, SQN) and
pyfoliointegration -
Flexible definition of commission schemes
-
Integrated broker simulation with Market, Close, Limit, Stop, StopLimit, StopTrail, StopTrailLimit and OCO orders, bracket order, slippage, volume filling strategies
-
Sizers for automated staking
-
Cheat-on-Close and Cheat-on-Open modes
-
Schedulers and Trading Calendars
-
Plotting (requires matplotlib)
Documentation
- Blog
- Documentation
- Indicators Reference (122 built-in indicators)
Python Support
- Python >= 3.9
- Also works with
pypyandpypy3(no plotting - matplotlib is not supported under pypy)
Installation
backtrader is self-contained with no external dependencies (except if you want to plot).
From PyPI:
pip install nijigen-backtrader
# With plotting support
pip install nijigen-backtrader[plotting]
Note: The minimum matplotlib version is 1.4.1
Optional Dependencies
For IB Data Feeds/Trading:
pip install git+https://github.com/blampe/IbPy.git
For other functionalities like Visual Chart, Oanda, TA-Lib, check the dependencies in the documentation.
Version Numbering
X.Y.Z.I
- X: Major version number
- Y: Minor version number (new features or API changes)
- Z: Revision version number (docs, small changes, bug fixes)
- I: Number of Indicators built into the platform
License
GPL-3.0-or-later
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nijigen_backtrader-1.9.78.123.tar.gz.
File metadata
- Download URL: nijigen_backtrader-1.9.78.123.tar.gz
- Upload date:
- Size: 290.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1d8f385103782771abc69ccb2917eb7e53a929521391114754a316814485286
|
|
| MD5 |
8655dfcd21843ecc1f222f5c070a8b16
|
|
| BLAKE2b-256 |
1771c22cbbe98e98d608628c9eed3fb7ebb944ceb7669393d53f340147d8a63c
|
File details
Details for the file nijigen_backtrader-1.9.78.123-py3-none-any.whl.
File metadata
- Download URL: nijigen_backtrader-1.9.78.123-py3-none-any.whl
- Upload date:
- Size: 418.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5780c16d565857f1057108c90a8dafaff4275b734271c8666dd006b5ca83a0e
|
|
| MD5 |
ddda68f9e9ddbd041985a00103e6c15c
|
|
| BLAKE2b-256 |
0eaba9c1a40aa9e69e9195d387dec53e80785f5304ae6287b467158f02bc6b40
|