Hi,
I am using Zipline with a local setup(WINDOWS 8 & Eclipse), and trying to build a independent backtesting framework. I create a python module like following codes in code sample.
Then I find something weird that when I run this in debugging mode. After initiate class AlgoStrategy, it go into the class Trading Algorithm then stopping at sim_params None check[if self.sim_params is None: ......] very long long time and the screen print msgs "[2015-05-05 06:41:20.136000] WARNING: Loader: No benchmark data found for date range.
start_date=2015-05-05 00:00:00+00:00, end_date=2015-05-05 06:41:19.679000, url=http://ichart.finance.yahoo.com/table.csv?a=4&c=2015&b=5&e=5&d=4&g=d&f=2015&s=%5EGSPC"
I do not konw why ,and can I do something to fix it?
from pytz import timezone
from zipline.algorithm import TradingAlgorithm
import matplotlib.pyplot as plt
import pandas as pd
central = timezone('Asia/Shanghai')
HOLDTIME = 5
COMMISSION = 0.005
class AlgoStrategy(TradingAlgorithm):
def initialize(self):
self.invested = False
self.trade_size = 1
self.long = False
self.short = False
self.closed = False
def handle_data(self, data):
print 'test'
def analyze(self, perf):
print 'test'
if __name__ == '__main__':
test = pd.read_csv('test.csv')
test = test.query("date>20150101")
test = test[['timestamp', 'open', 'high', 'low', 'close', 'volume', 'contract']]
test = test.set_index("timestamp")
test.index = pd.to_datetime(test.index, utc=True)
df = test
df['short_mavg'] = pd.rolling_mean(df['close'], 20)
df['long_mavg'] = pd.rolling_mean(df['close'], 100)
df = df.dropna()
Strategy = AlgoStrategy()
perf = Strategy.run(df)
Strategy.analyze(perf)