pmorissette/bt

Why does the start and end date in the results not match the inputs?

brettelliot opened this issue · 1 comments

Hi all,

Im curious why the start and end dates in the results don't match the inputs. For example, if I tell bt to start on '2018-01-01' and end on '2018-01-10', the results say the bactest started on 2017-12-31 and ended on 2018-01-11.

Thanks!
Brett

# From here
# https://pmorissette.github.io/bt/examples.html

import bt
import pandas as pd
%matplotlib inline

data = bt.get('BTC-USD', start='2018-01-01', end='2018-01-10')
sma = data.rolling(50).mean()
s = bt.Strategy('above50sma', [bt.algos.SelectWhere(data > sma),
                               bt.algos.WeighEqually(),
                               bt.algos.Rebalance()])

t = bt.Backtest(s, data, integer_positions=False, initial_capital=1000.0)
res = bt.run(t)
res.display()