Skip to main content

A quickly backtesting library for inversion strategies

Project description

Package nanobt (v 0.1.0)

A quickly backtesting library for inversion strategies

Install package

pip install nanobt

Data as pd.DataFrame

Columns required = ['datetime', 'open', 'high', 'low', 'close', 'volume']

Column 'datetime' must be datetime object.

Code example

from nanobt.backtesting import Backtesting
from nanobt.trades import TradeHistory, SideOrder
import pandas as pd

class BuyAndHoldStrategy(Backtesting):
    def next(self):
        if not self.position:

data = pd.read_csv('./data/binance_BTCUSDT_5m.csv')
data['datetime'] = pd.to_datetime(data['time'], unit='s')
data = data.drop(columns=['time'])

strategy = BuyAndHoldStrategy()
trades =

th = TradeHistory(trades=trades)
print("Init Portfolio: ", INIT_PORTFOLIO)
print("Buy and Hold Strategy: ",, sizer=1, commision=0.04, show_plot=False))

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

nanobt-0.1.1.tar.gz (3.5 kB view hashes)

Uploaded source

Supported by

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