Dear all,
I tried to follow the Tutorial 9 - Time Series History - RHistoryAPI and got stuck at the point when the vba code is supposed to jump from the Sub myRHistoryAPIExample to Sub
myRHistoryAPIExample_OnUpdate.
In my case the code was simply running through Sub myRHistoryAPIExample and never got to the OnUpdate sub.
I resolved the problem by using OnImage instead of OnUpdate and could then use a_historyTable in order to perform some checks in my code. However my code is only jumping from myRHistoryAPIExample to myRHistoryAPIExample_OnImage when I press F5 to run the code. In case I rund the code via F8 the macro will never jump out of myRHistoryAPIExample and never perform the code in the OnImage Sub.
Could please somebody help and explain how and when OnUpdate and OnImage are triggered?
Many thanks in advance,
Richard
Private Sub myRHistoryAPIExample()
Dim strFldList As String
Dim myResult As String
Dim a_historyTable As Variant
Dim rw As Integer, col As Integer
On Error GoTo ErrorHandler
Set myRHistoryManager = CreateRHistoryManager
myRHistoryCookie = myRHistoryManager.Initialize("MY BOOK")
Set myRHistoryQuery = myRHistoryManager.CreateHistoryQuery(myRHistoryCookie)
With myRHistoryQuery
.InstrumentIDList = .BKXU
.FieldList = "TRDPRC_1.TIMESTAMP;TRDPRC_1.CLOSE"
.RequestParams = "INTERVAL:1D START:20-DEC-1999 END:05-JAN-2000"
.DisplayParams = "Sort:A CH:Fd"
.RefreshParams = ""
.Subscribe
End With
Exit Sub
ErrorHandler:
Debug.Print Err.Number & ": " & Err.Description
End Sub
Private Sub myRHistoryQuery_OnImage(ByVal a_historyTable As Variant)
Dim rw As Integer, col As Integer
For rw = LBound(a_historyTable, 1) To UBound(a_historyTable, 1)
For col = LBound(a_historyTable, 2) To UBound(a_historyTable, 2)
Range("C1").Offset(rw, col).Value = a_historyTable(rw, col)
Next col
Next rw
End Sub