Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
From Index to Sid

data.current, data.history, USEquityPricing, are what I'm refering to as functions. If you have a dataFrame with indexes 'Equity(43681 [WHF])' and add a column that calculates the price of that stock in that row using the index of that row, how to you get the SID to put into the function?

Almost every example code, directly enters SIDs. Also, I can't find a way to use the SYMBOL to get the SID to put into the function.

These "functions" only accept sid's and I cannot find a clear example of going from an INDEX to a sid anywhere.

I'm trying to use this in a scheduled function. Thanks.

7 responses

Hi Jared, an Equity object can be passed into data.current or data.history just fine. It doesn't need to be converted to a SID.

When do you need to use a symbol to get a SID?

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

How can I access an equity object? How do I pass it to data.current or data.history? The symbol to sid was a last ditch effort to get data.current to return 'price.'

'Equity(43681 [WHF])' is an equity object. It can be used as the first argument to data.current or data.history.

If you have a DataFrame with Equity objects in the index, you can take df.index (if your DataFrame is called df) and use it as the first argument of data.current or data.history to get a Series or DataFrame respectively with data for all equities in the index.

Here is the documentation for data.current and data.history.

Smh. I could have sworn I tried that. It works though. Thanks!

New question!? How do I pass the list of equity objects (i.e. the index) to order()?

I tried order
this --> order(context.pick_list.index, ord_amt)

this --> order(context.pick_list.index.symbol, ord_amt)

and this --> order(context.pick_list['symbol'], ord_amt)

This is the runtime error message:
UnsupportedOrderParameters: Passing non-Asset argument to 'order()' is not supported. Use 'sid()' or 'symbol()' methods to look up an Asset.
There was a runtime error on line 220.

THANKS!

order isn't vectorized, so you can only pass in one equity at a time. So you can iterate through context.pick_list.index using a for loop and place your orders for each one individually.

YES! My first algo is running! Muahahahhahahahaha! Thanks Nathan.