Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
unable to get Australian stock's close with symbols

I have tried the following code in order to get Australian stock's close:

from quantopian.pipeline import Pipeline
from quantopian.pipeline.data import EquityPricing
from quantopian.pipeline.domain import AU_EQUITIES
from quantopian.research import run_pipeline
from quantopian.research import returns, symbols

Get the latest daily close price for all equities.

yesterday_close = EquityPricing.close.latest

Get the latest daily trading volume for all equities.

yesterday_volume = EquityPricing.volume.latest

Add our data columns to our pipeline and specifies the domain

to be AU_EQUITIES.

pipe = Pipeline(
columns={
'close': yesterday_close,
'volume': yesterday_volume,
},
domain=AU_EQUITIES,
)

Run the pipeline over a one year period and print the output.

df = run_pipeline(pipe, '2015-05-05', '2016-05-05')
print(df.head())

list(df.index.levels[1])
print(symbols('BXB'))

bxb_output = data_output.xs(
symbols('BXB'),
level=1
)

It works well for US_equities with AAPL example, but it doesn't work for Australian stocks. In the result data frame, I have 'BXB' as
Equity(1178883433190225 [BXB]). However symbols('BXB') give me Equity(23486 [BXB]). How could I get the right id to retrieve
single stock's data?

1 response

Using the stock ticker in the symbols method is currently only supported for US equities. Non-US equities must be referenced using the SID. Like this

bxb = symbols(1178883433190225)

The symbols method can be used but with the SID value instead of the ticker.

Getting the SID takes a couple of steps. First, get a pipeline of all the securities. Next, add columns for SID, ticker, and company name to the resulting dataframe. Finally, search the dataframe by ticker or name and find the corresponding SID.

That SID can then be used to filter a pipeline. Take a look at the attached notebook for how this could be implemented.

There are a couple of posts on this topic which may also be of interest.
https://www.quantopian.com/posts/sid-using-exchange-ticker-symbol-for-indian-securities-in-research
https://www.quantopian.com/posts/identifying-the-ticker-symbols-for-global-equity-indian-market

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.