Hi,
I'm new to both programming and this site. How would I edit this algorithm to check every stock in the market instead of just GOOG?
def initialize(context):
context.sid = sid(26578)
context.invested = False
def handle_data(context, data):
context.price = data[context.sid].price
short = data[context.sid].mavg(50)
long = data[context.sid].mavg(200)
if (short > long) and not context.invested:
order(context.sid, 10)
context.invested = True
elif (short < long) and context.invested:
order(context.sid, -10)
context.invested = False
record(short_mavg = short,
long_mavg = long,
goog_price = context.price)
Thanks!