@batch_transform(refresh_period=1, window_length=10)
def get_values(datapanel):
# We are looking for the min and the max price to return. Just because it's interesting
# we also are logging the current price.
prices_df = datapanel['price']
min_price = prices_df.min()
max_price = prices_df.max()
print("Prices:")
myDT=get_datetime()
print(prices_df[myDT,sid(8554)])
if min_price is not None and max_price is not None:
return (max_price, min_price)
else:
return None
When doing a batch transform, is there a way to access the last day's data? So for example, what if I wanted to return the last day's price divided by the 10 day average price (I know this can be done with simple transforms but how would I do it as a batch transform)? So if I call
print(prices_df[sid(8554)])
I get the prices for ONLY sid(8554). But how would I ONLY get the prices for latest date? I tried
myDT=get_datetime()
print(prices_df[myDT])
and I get the error message
KeyError: no item named 2013-01-17 00:00:00+00:00 File
test_algorithm_sycheck.py:18, in handle_data File
/zipline/transforms/batch_transform.py:202, in handle_data File
/zipline/transforms/batch_transform.py:267, in get_transform_value
File test_algorithm_sycheck.py:77, in get_values File frame.py:1928,
in getitem File generic.py:570, in get_item_cache File
internals.py:1383, in get File internals.py:1525, in _findblock File
internals.py:1532, in _check_have