Notebook

get_pricing vs data.history methods

verify the two return the same data

In [12]:
# make a list of the securities one wishes to get pricing for
my_symbol = symbols('AAPL')

# set the start and stop date-time.
# note that times are specified in UTC 
# Also note that the data is split and dividend adjusted per the end date
start_date = '2017-12-17'
end_date = '2017-12-19'
In [13]:
prices = get_pricing(my_symbol, fields='price', start_date=start_date, end_date=end_date, frequency='minute').dropna() 
prices
Out[13]:
2017-12-18 14:31:00+00:00    175.090
2017-12-18 14:32:00+00:00    175.168
2017-12-18 14:33:00+00:00    175.550
2017-12-18 14:34:00+00:00    175.690
2017-12-18 14:35:00+00:00    175.770
2017-12-18 14:36:00+00:00    175.700
2017-12-18 14:37:00+00:00    175.360
2017-12-18 14:38:00+00:00    175.280
2017-12-18 14:39:00+00:00    175.540
2017-12-18 14:40:00+00:00    175.550
2017-12-18 14:41:00+00:00    175.490
2017-12-18 14:42:00+00:00    175.590
2017-12-18 14:43:00+00:00    175.680
2017-12-18 14:44:00+00:00    175.730
2017-12-18 14:45:00+00:00    175.745
2017-12-18 14:46:00+00:00    175.910
2017-12-18 14:47:00+00:00    175.930
2017-12-18 14:48:00+00:00    175.919
2017-12-18 14:49:00+00:00    175.740
2017-12-18 14:50:00+00:00    175.890
2017-12-18 14:51:00+00:00    175.904
2017-12-18 14:52:00+00:00    175.925
2017-12-18 14:53:00+00:00    175.975
2017-12-18 14:54:00+00:00    176.050
2017-12-18 14:55:00+00:00    176.090
2017-12-18 14:56:00+00:00    176.100
2017-12-18 14:57:00+00:00    176.161
2017-12-18 14:58:00+00:00    176.150
2017-12-18 14:59:00+00:00    176.220
2017-12-18 15:00:00+00:00    176.210
                              ...   
2017-12-19 20:31:00+00:00    174.550
2017-12-19 20:32:00+00:00    174.520
2017-12-19 20:33:00+00:00    174.565
2017-12-19 20:34:00+00:00    174.550
2017-12-19 20:35:00+00:00    174.545
2017-12-19 20:36:00+00:00    174.487
2017-12-19 20:37:00+00:00    174.480
2017-12-19 20:38:00+00:00    174.459
2017-12-19 20:39:00+00:00    174.430
2017-12-19 20:40:00+00:00    174.490
2017-12-19 20:41:00+00:00    174.515
2017-12-19 20:42:00+00:00    174.600
2017-12-19 20:43:00+00:00    174.540
2017-12-19 20:44:00+00:00    174.470
2017-12-19 20:45:00+00:00    174.485
2017-12-19 20:46:00+00:00    174.460
2017-12-19 20:47:00+00:00    174.315
2017-12-19 20:48:00+00:00    174.300
2017-12-19 20:49:00+00:00    174.300
2017-12-19 20:50:00+00:00    174.220
2017-12-19 20:51:00+00:00    174.310
2017-12-19 20:52:00+00:00    174.395
2017-12-19 20:53:00+00:00    174.420
2017-12-19 20:54:00+00:00    174.370
2017-12-19 20:55:00+00:00    174.480
2017-12-19 20:56:00+00:00    174.445
2017-12-19 20:57:00+00:00    174.410
2017-12-19 20:58:00+00:00    174.400
2017-12-19 20:59:00+00:00    174.340
2017-12-19 21:00:00+00:00    174.530
Name: Equity(24 [AAPL]), dtype: float64
In [14]:
# Let's change this to ET so it's easier to read
prices_et = prices.tz_convert('US/Eastern')

# Check the latest 20 prices
prices_et.tail(20)
Out[14]:
2017-12-19 15:41:00-05:00    174.515
2017-12-19 15:42:00-05:00    174.600
2017-12-19 15:43:00-05:00    174.540
2017-12-19 15:44:00-05:00    174.470
2017-12-19 15:45:00-05:00    174.485
2017-12-19 15:46:00-05:00    174.460
2017-12-19 15:47:00-05:00    174.315
2017-12-19 15:48:00-05:00    174.300
2017-12-19 15:49:00-05:00    174.300
2017-12-19 15:50:00-05:00    174.220
2017-12-19 15:51:00-05:00    174.310
2017-12-19 15:52:00-05:00    174.395
2017-12-19 15:53:00-05:00    174.420
2017-12-19 15:54:00-05:00    174.370
2017-12-19 15:55:00-05:00    174.480
2017-12-19 15:56:00-05:00    174.445
2017-12-19 15:57:00-05:00    174.410
2017-12-19 15:58:00-05:00    174.400
2017-12-19 15:59:00-05:00    174.340
2017-12-19 16:00:00-05:00    174.530
Name: Equity(24 [AAPL]), dtype: float64

Below is the data cut and psted from the algorithm log. Looks like they match perfectly.

2017-12-19 15:41:00-05:00 174.515 2017-12-19 15:42:00-05:00 174.600 2017-12-19 15:43:00-05:00 174.540 2017-12-19 15:44:00-05:00 174.470 2017-12-19 15:45:00-05:00 174.485 2017-12-19 15:46:00-05:00 174.460 2017-12-19 15:47:00-05:00 174.315 2017-12-19 15:48:00-05:00 174.300 2017-12-19 15:49:00-05:00 174.300 2017-12-19 15:50:00-05:00 174.220 2017-12-19 15:51:00-05:00 174.310 2017-12-19 15:52:00-05:00 174.395 2017-12-19 15:53:00-05:00 174.420 2017-12-19 15:54:00-05:00 174.370 2017-12-19 15:55:00-05:00 174.480 2017-12-19 15:56:00-05:00 174.445 2017-12-19 15:57:00-05:00 174.410 2017-12-19 15:58:00-05:00 174.400 2017-12-19 15:59:00-05:00 174.340