I'd like to get a numerical value of the ratio of the spy and the soxx, what is the best way to do this?
def initialize(context):
context.stocks = symbols('SPY','qqq','soxx') # list of stocks
context.minuteCounter = 0 # this tracks number of handle_data calls
spy = int(sid(8554))
sox = int(sid(22904))
ratio = (sox-spy)
print ratio
def handle_data(context, data):
# increment the minute counter
context.minuteCounter += 1
y = context.minuteCounter
if context.minuteCounter >= 30:
context.minuteCounter = 0
# trade logic:
spy = context.stocks[0] # get the first stock in the list
sox = context.stocks[2]
#ratio = sox/spy
prices = history(bar_count = 26, frequency = '1m', field = 'price')
prices.