Hi.
I've been going mad trying to get daily returns of a backtest I have into Pyfolio. No matter which way I twist the data it seems to be throwing an error. Using the code,
import pyfolio as pf
import pandas as pd
returns = pd.read_csv('returnsTZ2.txt')
returns.columns = [ 'date', 'return']
returns['date'] = pd.to_datetime(returns['date'])
print(returns)
returns = returns.set_index(['date'])
pf.create_returns_tear_sheet(returns, live_start_date='2016-6-6')
2014-12-08 01:00:00 0.000831
2014-12-09 01:00:00 0.043870
2014-12-10 01:00:00 -0.002749
2014-12-11 01:00:00 -0.009615
2014-12-12 01:00:00 -0.021883
2014-12-15 01:00:00 -0.017754
2014-12-16 01:00:00 -0.002320
I'm getting this error,
TypeError: Cannot compare tz-naive and tz-aware timestamps
Then changing the date data with this code,
import pyfolio as pf
import pandas as pd
filename = 'returnsTZ2.txt'
returns = pd.read_csv(filename,sep=',')
returns.columns = [ 'date', 'return']
returns['date'] = pd.to_datetime(returns['date'],format='%Y-%m-%d %H:%M:%S')#,utc=None)
returns = returns.set_index(['date'])
returns.index = pd.to_datetime(returns.index)
returns.index = returns.index.tz_localize('GMT')
pf.create_returns_tear_sheet(returns, live_start_date='2016-6-6')
2014-12-11 01:00:00+00:00 -0.009615
2014-12-12 01:00:00+00:00 -0.021883
2014-12-15 01:00:00+00:00 -0.017754
2014-12-16 01:00:00+00:00 -0.002320
2014-12-17 01:00:00+00:00 0.008124
2014-12-18 01:00:00+00:00 0.016539
2014-12-19 01:00:00+00:00 0.002284
2014-12-22 01:00:00+00:00 -0.013383
unsupported operand type(s) for +: 'int' and 'str'
Anyone have any suggestions as to where I'm going wrong. I have been able to run the tear sheet example here http://quantopian.github.io/pyfolio/notebooks/single_stock_example/