Pull Closing Prices Without Market Holidays

Hello, with this request in Excel using PI#S and DN (A2 = S&PCOMP ticker):


=@DSGRID(Data!$A$2,"X(PI#S)","2021-12-31","","DN","RowHeader=true;ColHeader=true;DispSeriesDescription=false;YearlyTSFormat=false;QuarterlyTSFormat=false;AutoRefresh=false","")

I am able to pull the S&P 500 last value excluding holidays (dates).

How I can translate this method in python code for CodeBook ? Could you provide an example that matches the same output I obtain in Excel ?

Best Answer

  • Jirapongse
    Jirapongse admin
    Answer ✓

    @Aleniles

    You can try this one:

    ds.get_data(tickers="@AMZN",fields =["PO", "PH","PL","P#S"], freq="DN", kind=1)

    However, please contact the Refinitiv Datastream Web Service support team directly via MyRefinitiv to confirm it and ask for the way to obtain market holidays (dates) in Datastream for a given country.


Answers

  • @Aleniles

    The code looks like this.

    Price = ds.get_data('S&PCOMP', fields=['X(PI#S)'], start='2021-12-31', freq='DN')
    Price

    The output is:

    1652322459495.png



  • Thanks! Is there also a way to obtain market holidays (dates) in Datastream for a given country using python ?

  • How to do the same (removing holidays) but fetching the Open, high, low and close using a stock like @AMZN ?