I tried changing the sid on the sample algorithm . I used symbol goog. It worked once but I still received the aapl results. Can anyone enlighten me?
I tried changing the sid on the sample algorithm . I used symbol goog. It worked once but I still received the aapl results. Can anyone enlighten me?
Can you do a full backtest and then attach the backtest to your reply? That will share with us the source code you are trying to use.
Here is some information from the help page: https://www.quantopian.com/help#ide-sid-lookup
Thank you for your reply. I find if after I enter the sid, I change the symbol manually wherever a symbol appears in the formula, it works. Does this seem to make sense. i.e goog is the sid, I manually enter goog at lines 34,37,43,51,53.
Hi August, I don't know what those line number are. Please share the source code (by attaching a backtest).
# security ID
context.ma = sid(32146)
context.max_notional = 1000000.1
context.min_notional = -1000000.0
def handle_data(context, data):
vwap = data[context.ma].vwap(50)
price = data[context.ma].price
notional = context.portfolio.positions[context.ma].amount * price
if price < vwap * 0.995 and notional > context.min_notional:
order(context.ma,-100)
elif price > vwap * 1.005 and notional < context.max_notional:
order(context.ma,+100)
Does this help?
@August, you can edit your post (use the pencil icon) and use "Code Sample - Ctrl-K" to format the code block.
# This is a code sample
Now to answer your question. When you use the sid() function you are getting a stock symbol from an identifier number. You can get information about that stock:
# price of GOOG
price = data[sid(26578)].price
If you set a variable (context.goog) to sid(26578) you don't have to re-type it all over the place and possibly make a mistake in the number.
# GOOG
context.goog = sid(26578)
# price of GOOG
price = data[context.goog].price
In the example you pasted the variable is context.ma and is set to sid(32146) for MA (Mastercard)
But you don't have to name the variable after the stock symbol.
context.mystock = sid(26578)
price = data[context.mystock].price
Does that make sense?