Closed rhodan closed 7 years ago
@llllllllll I think you recently merged a change that fixed a bug that was crashing with the same error Does this ring a bell to you?
The recent indexerror I dealt with was in the blaze loader, I think this my be a dup of: #447
I found it works well with zipline 0.7.0
from zipline.algorithm import TradingAlgorithm
from zipline.api import symbol, order, record
from zipline.sources.simulated import RandomWalkSource
from zipline.utils import tradingcalendar as calendar_nyse
from datetime import datetime
import pytz
from zipline.api import *
start_date = datetime(2014, 1, 1, 0, 0, 0, 0, pytz.utc)
end_date = datetime(2014, 2, 10, 0, 0, 0, 0, pytz.utc)
source = RandomWalkSource(start_prices={0: 100, 1: 500}, freq='minute', start=start_date,
end=end_date,calendar=calendar_nyse)
def initialize(context):
add_history(5, '1m', 'price')
def handle_data(context, source):
price_history = history(5, '1m', 'price')
print("recent", price_history)
algo = TradingAlgorithm(initialize=initialize, handle_data=handle_data)
perf = algo.run(source)
recent 0 1
2013-12-31 20:57:00+00:00 NaN NaN
2013-12-31 20:58:00+00:00 NaN NaN
2013-12-31 20:59:00+00:00 NaN NaN
2013-12-31 21:00:00+00:00 NaN NaN
2014-01-02 14:31:00+00:00 99.916265 500.154655
recent 0 1
2013-12-31 20:58:00+00:00 NaN NaN
2013-12-31 20:59:00+00:00 NaN NaN
2013-12-31 21:00:00+00:00 NaN NaN
2014-01-02 14:31:00+00:00 99.916265 500.154655
......
then I tried resample minute level data to daily frequency
source = RandomWalkSource(start_prices={0: 100, 1: 500}, freq='minute', start=start_date,
end=end_date,calendar=calendar_nyse)
def initialize(context):
add_history(5, '1d', 'price')
def handle_data(context, source):
price_history = history(5, '1d', 'price')
print("recent", price_history)
and I get indexerror
......
-> 1354 val = getitem(key)
1355 return Timestamp(val, offset=self.offset, tz=self.tz)
1356 else:
IndexError: index 0 is out of bounds for axis 0 with size 0
I think its quiet important for traders to use daily prices on minute level.
Hi @rhodan I'm going to close this issue in favor of other issues opened right now that also use our most current zipline API. Feel free to open a new issue or comment on one of the existing issues labeled with Minute Mode
😄
again,
I wonder if history() function works on minute level data.
It works well on daily basis.