Obtain Closing Price of stock on set series of dates and return NULL if there is not data for that d

Hi All,

How can I obtain the daily closing price for a stock for specified dates, returning NULL on any specific dates that do not have data?

I'd like to obtain the daily price of several stocks over a set period of time.
Ideally my output will look like this:

1723732176751.png


Where a day that the latest closing price is not available returns a NULL value.

But, when I run the following code, I get data available for the LAST valid closing price -- which I don't want.
Unfortuneately, my output looks like this, repeating the date/value for 7/1/24:

1723732197000.png

I've simplified the example and limited the size of the tables above, but this is the code I am using to pull this data on a real stock. The problem is the same as described above.
CODE:

df = rd.get_data(
universe = [ 'A1OS34.SA'],
fields = ['TR.PriceClose.date', 'TR.PriceClose'],
parameters = {
'SDate': '2024-06-01',
'EDate': '2024-08-01',
'Frq': 'D',
'Curn': 'USD'
}
)

display(df)


I appreciate any help folks can provide -- thanks!

Answers

  • @DMangoubi

    Thank you for reaching out to us.

    You may need to contact helpdesk via MyAccount to verify the content and parameters.

    Otherwise, you can try the rd.get_history instead.

    rd.get_history(
        ["A1OS34.SA"],
        fields=["TRDPRC_1"],
        start='2024-06-01',
        end='2024-08-01',
        interval='daily')

    1723780794790.png


  • Thank you @ Jirapongse ! Do you know what the process for getting this in the Excel plug in would be? Or if there is a way of doing this with the time series command? Thanks!

  • @DMangoubi

    It could be this formula in Workspace Excel.

    =@RDP.HistoricalPricing("A1OS34.SA","TRDPRC_1","INTERVAL:P1D SOURCE:RFV",,"CH:Fd RH:Timestamp",E2)
  • Jirapongse!
    Is there a way to specify currency for the get_history function? Or, if I can't specify currency, can I display the currency the stock data is returned in?

  • @DMangoubi

    As far as I know, we can't specify the currency for the historical real-time data retreived via the get_history method..

    We can specify the currency when using the get_data method with the TR.xxx fields.

    You can get the currency of the real-time data by using the following code.

    rd.get_data(
        universe=['A1OS34.SA'],
        fields=['CF_CURR']
    )