question

Upvotes
Accepted
5 1 2 2

Rounding price index data

Hi there - I am trying the below code and see all the prices as .1 for the first ticker and as 0 for the second ticker; believe because the prices are very small in US dollar terms and so rounding of 1 decimal is not helping. Would you be able to advise how to change the code to see 3 or 4 decimals?

ds.fetch(tickers=['UKB23X1H3','UKBGHWH98','UKB064SH8'], fields=['X(PI)~U$'], date_from= '2021-01-31', date_to= '2021-04-14', freq= 'W')

datastream-apidsws-api
ds-price.jpg (55.1 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvote
Accepted
79.1k 250 52 74

@Avik Saha

You can use the number of decimal places (DPL#) expression.

The code looks like this:

DS.fetch(tickers=['UKB23X1H3','UKBGHWH98','UKB064SH8'], fields=['DPL#(X(PI)~U$,4)'], date_from= '2021-01-31', date_to= '2021-04-14', freq= 'W')
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks, @jirapongse.phuriphanvichai, exactly what i was looking for.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.