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

...t date?

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!

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @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


Answers