question

Upvotes
Accepted
24 1 0 4

Datastream API (REST_POST): Returned equity prices are off by a factor of 100 to 10000

I have downloaded the „Excel VBA Sample” (v1.2, 24 Jul 2020) file from the Datastream product website (http://product.datastream.com/DswsClient/Docs/Downloads.aspx).


I have made some minor changes on the “DatastreamRequests” tab (shown in red in the screenshot) and clicked on the “Get Data Bundle (REST_POST)” button.


datastreamrequests.jpg


The returned equity prices as shown in red in the screenshot of the tab “DatastreamResponses” are off by a factor of 100 to 10000.


datastreamresponses.jpg


My environment is Windows 10, Office 365.

dsws-api
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.

Upvote
Accepted
78.9k 250 52 74

@IoannisG

I used this example on this website to check a decimal character.

If it is ',', I replace a dot character with a comma character before converting a string to a double.

 If ValueType = "DoubleArray" And ValueText <> "NaN" Then
    If GetInfo(LOCALE_SDECIMAL) = "," Then
       ValueText = Replace(ValueText, ".", ",")
    End If
    Values(CounterValue, 1) = CDbl(ValueText)
 Else
   Values(CounterValue, 1) = ValueText
 End If

1660042839118.png

Then, use the GetInfo function when converting a string to a double.

1660042964079.png

There are two places of this code in the InterpretDataResponse function.



1660042839118.png (75.1 KiB)
1660042964079.png (27.0 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.

The output looks like this:

1660043091812.png

1660043091812.png (120.5 KiB)
Upvotes
78.9k 250 52 74

@IoannisG

I am unable to replicate this issue.

My output looks like this.

1660035901881.png

It looks like that your output doesn' have decimal characters (.).

Please check if other outputs have decimal characters (.).

1660036950227.png


1660035901881.png (28.3 KiB)
1660036950227.png (120.5 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.

Upvotes
24 1 0 4

Thanks for your reply, I have checked and there are indeed no decimal characteres in any of the output.


My Windows 10 and MS Office 365 locale is German, where the decimal separator is the ',' character, and the thousands separator is the '.' character. Could this be the problem? If so, what do I need to change in the VBA code of the „Excel VBA Sample” file to address this?

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.

Upvotes
24 1 0 4

Many thanks, this seems to work.


Instead of the GetInfo(LOCALE_SDECIMAL) function I used the alternative:


Public Function GetDecimalSeparator()
GetDecimalSeparator = Mid(Format(1000, "#,##0.00"), 6, 1)
End Function


and the output is now correctly shown for my locale.

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.

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.