Why is that these two prints of close prices don't agree on notebook vs algorithm? (see the close price before last)
Notebook:
from datetime import timedelta
from quantopian.research.experimental import history, continuous_future
import scipy.stats
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#import matplotlib.patches as mpatches
import alphalens
from statsmodels.regression.linear_model import OLS
from statsmodels.tools.tools import add_constant
data = history(
continuous_future('TU', adjustment=None, roll='calendar'),
fields = ['open_price','high','low','close_price','contract'],
frequency = 'daily',
start = '2010-01-01',
end = '2013-01-01'
)
list(data['close_price'].loc[:"2012-07-16"][-30:])
Output:
[110.234375, 110.203125, 110.203125, 110.1953125, 110.1875, 110.1484375, 110.1484375, 110.1328125, 110.1796875, 110.15625, 110.140625, 110.09375, 110.109375, 110.1015625, 110.125, 110.1015625, 110.109375, 110.109375, 110.1171875, 110.125, 110.078125, 110.1171875, 110.140625, 110.1796875, 110.203125, 110.203125, 110.203125, 110.2265625, 110.2578125, 110.2890625]
Algorithm code:
from zipline.api import continuous_future, schedule_function
from zipline.api import time_rules, date_rules, record
#from zipline.algorithm import log
#from zipline.assets.continuous_futures import ContinuousFuture
from zipline.api import order_target_value, order_target_percent
from zipline.utils.calendars import get_calendar
import numpy as np
import scipy as sp
import pandas as pd
#from quantopian.algorithm import order_optimal_portfolio
#import quantopian.optimize as opt
def initialize(context):
schedule_function(my_rebalance, date_rules.every_day(), time_rules.market_open(minutes=30))
def my_rebalance(context, data):
f = continuous_future("TU", offset=0, roll='calendar', adjustment=None)
ohlc = data.history(f,
['open','high','low','close'],
100,
'1d')[:-1]
log.info(list(ohlc['close'][-30:]))
Output:
2012-07-17 12:00 my_rebalance:24 INFO [110.23399999999999, 110.203, 110.203, 110.19499999999999, 110.187, 110.148, 110.148, 110.13200000000001, 110.179, 110.15600000000001, 110.14, 110.093, 110.10899999999999, 110.101, 110.125, 110.101, 110.10899999999999, 110.10899999999999, 110.117, 110.125, 110.078, 110.117, 110.14, 110.179, 110.203, 110.203, 110.203, 110.226, 110.25700000000001, 110.289]