Skip to main content

BackTesting Engine - A feature-rich Python framework for backtesting and trading

Project description

nijigen-backtrader

PyPI Version License Python versions

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 IbPy and benefits greatly from an installed pytz)
    • Visual Chart (needs a fork of comtypes)
    • Oanda (needs oandapy) (REST API Only)
  • 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 pyfolio integration

  • 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

Python Support

  • Python >= 3.9
  • Also works with pypy and pypy3 (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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nijigen_backtrader-1.9.78.124.tar.gz (290.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nijigen_backtrader-1.9.78.124-py3-none-any.whl (418.2 kB view details)

Uploaded Python 3

File details

Details for the file nijigen_backtrader-1.9.78.124.tar.gz.

File metadata

  • Download URL: nijigen_backtrader-1.9.78.124.tar.gz
  • Upload date:
  • Size: 290.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for nijigen_backtrader-1.9.78.124.tar.gz
Algorithm Hash digest
SHA256 bb64d4a9dc0f508543f5a22f26f39fc48116adb4afdd3511ba6e35469f5b2b5a
MD5 6c495923664d639c57c57de8f8809a6f
BLAKE2b-256 5d977a0719584c730728d6dbc7854ede1d54aa4ce5f89f2447d00ee9c0d3a7df

See more details on using hashes here.

File details

Details for the file nijigen_backtrader-1.9.78.124-py3-none-any.whl.

File metadata

File hashes

Hashes for nijigen_backtrader-1.9.78.124-py3-none-any.whl
Algorithm Hash digest
SHA256 b7554ffc4c4f942be1f2be65d79dbb2d2a57d2532e6c379fd775f0ae88447597
MD5 2c7bb4c72337df63457d52b7cf5a17df
BLAKE2b-256 e06c02eef1e788733c88972664ea494da486e8cf5dd7c6d432ca1400012316b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page