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

Options

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.

Tagged:

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @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.


Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @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

  • 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?

  • 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.