Skip to content

Simples Framework to Backtest Strategies using pandas

License

Notifications You must be signed in to change notification settings

Janderson/pandasbt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PandasBT

Simples Framework to Backtest Strategies using pandas

Resume:

Installation


pip install pandasbt

Calculating 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")

Calculating 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")

Calculate a Higher Timeframe (Like D1) using a Lower Timeframe (Like M5)

import pandasbt as pbt
pbt.build_timeframe(df_test, timeframe="M5)

About

Simples Framework to Backtest Strategies using pandas

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages