I thought if you obtain the historical data via data.history ... then it's automatically in the data type of "list of list" but it seems like it's not.
def initialize(context):
context.securities = [sid(24),sid(114)]
for i in range(1,390,30):
schedule_function(open_positions,date_rules.every_day(),time_rules.market_open(minutes=i))
def open_positions(context, data):
# obtaining historical data (previous 50 data points at 30 minutes frequency)
period = 50
timeframe = 30
timeframe_unit = 'T'
bars_1m = period*timeframe
timeframe_string = str(timeframe) + timeframe_unit
hist = data.history(context.securities, 'price', bars_1m, '1m').resample(timeframe_string).last().ffill().iloc[-1]
#-------------------------
with this, if I do print hist then it does print historical close prices, and I can even do len(hist) which would be the total number of securities defined but if I go like, say, len(hist[0]) or even print hist[0][0] it doesn't work saying it's an "invalid index to a scalar variable"
which leads me thinking it's really just a 1D array in which its components just define the securities ID
How can I transform it into a 2D array (list of list), say myMatrix, in which myMatrix[5][10] would represent 10th oldest data of the 5th securities