Skip to main content

Simple framework to test your strategies ideias with pandas

Project description

PandasBT

Simples Framework to Backtest Strategies using pandas

Installation


pip install pandasbt

Calculation a factor zscore

import pandasbt as pbt

df_test = pd.DataFrame([
    {"close": 25}, {"close": 15}, {"close": 41}, {"close": 7},
    {"close": 5}, {"close": 115}, {"close": 45}, {"close": 32},
])

pbt.zscore(df_test, period=20)

or you can specify the column

pbt.zscore(df_test, 20, "close")

Calculation Buy and Sell signals

That mean add a signal column into dataframe.
0 - means nothing
-1 - means sell
1 - means buy

import pandasbt as pbt

df_test = pd.DataFrame([
    {"close": 25}, {"close": 15}, {"close": 41}, {"close": 7},
    {"close": 5}, {"close": 115}, {"close": 45}, {"close": 32},
])

pbt.calc_signal(df_test, buy_query="close > 20", sell_query="close < 10")

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

pandasbt-0.1.1.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

pandasbt-0.1.1-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

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