我有两个对象,我想计算每个值的值差异。
代码现在是:
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
它们基于另一个功能:
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
因此,我们的想法是比较Bloomberg的两只不同股票。因此,我需要能够计算股票价格的差异。
我该怎么做?