I have two objects and I want to calculate the difference in values for each value.
The code is now:
Function CALBETA(CodeOne As String, CodeTwo As String) As Double
Dim onedata As Object
Dim Twodata As Object
Set onedata = ConnectToBloombergTwo(CodeOne)
Set Twodata = ConnectToBloombergTwo(CodeTwo)
End Function
They are based on another function:
Public Function ConnectToBloombergOne(Code As String) As Object
Dim sUrl As String
Dim rawJson As Dictionary
Dim dataRequest As WinHttp.WinHttpRequest
Dim Json As Object
Dim FetchedData As String
sUrl = "http://www.bloomberg.com/markets/api/bulk-time-series/price/" & Code & "?timeFrame=3_YEAR"
Set dataRequest = New WinHttp.WinHttpRequest
With dataRequest
.Open "GET", sUrl, True
.Send
.WaitForResponse
FetchedData = .ResponseText
End With
FetchedData = Right(FetchedData, Len(FetchedData) - 1)
FetchedData = Left(FetchedData, Len(FetchedData) - 1)
Set Json = JsonConverter.ParseJson(FetchedData)
Set ConnectToBloombergOne = Json.Item("price")
End Function
So, the idea is to compare two different stocks from Bloomberg. Therefore, I need to be able to calculate the difference in the stock price.
How can I do that?