How to show results of a RHistory query with VBA into an Excel sheet?

I would like to write into the cell A1 of an Excel sheet the result of the query below, but I don't know what I need to do :
Set myRHistoryManager = CreateHistoryManager
myRHistoryCookie = myRHistoryManager.Initialize("MY BOOK")
Set myRHistoryQuery = myRHistoryManager.CreateHistoryQuery(myRHistoryCookie)
' Set the query parameters accordingly to your needs
With myRHistoryQuery
.InstrumentIdList = "VOWG5YEUAM=R" ' Range("G6").Value
.FieldList = "MID_SPREAD.Timestamp;MID_SPREAD.Close" ' Range("G7").Value 'Or of the form "TRDPRC_1.TIMESTAMP;TRDPRC_1.VALUE;TRDPRC_1.VOLUME"
.RequestParams = "START:" & CDbl(ActiveSheet.Range("A1").Value) & " END:" & CDbl(ActiveSheet.Range("A2").Value) & " INTERVAL:1D" ' Range("G8").Value
.RefreshParams = "FRQ:5S" ' Range("G9").Value
.DisplayParams = "" ' ActiveSheet.Range("G10").Value '"TSREPEAT:YES CH:Fd"
.Subscribe
End With
Exit Sub
Where do I have to write the cell on which I want the result?
Thanks
Best Answer
-
I have modified the Basic.sample.xlsm to display the result at Cell A1.
Private Sub m_rhistoryQuery_OnImage(ByVal a_historyTable As Variant)
' TODO: Use the data in the array a_historyTable
Range(Cells(1, 1), Cells(UBound(a_historyTable, 1), UBound(a_historyTable, 2))).Value = a_historyTable
End Sub
Private Sub m_rhistoryQuery_OnUpdate(ByVal a_historyTable As Variant, ByVal a_startingRowIndex As Long, ByVal a_startingColumnIndex As Long, ByVal a_shiftDownExistingRows As Boolean)
Range(Cells(1, 1), Cells(UBound(a_historyTable, 1), UBound(a_historyTable, 2))).Value = a_historyTable
End Sub0
Answers
-
Hello @benoit.laurent2,
You may find useful RHistory API Examples, Single-Query Sample Excel book conveys output via Cells.
Does this help?
0 -
Thank you, but it doesn't help me to understand where I have to give the cell where the answer of the query must be written. By default, in RHistoryAPI.xlsm, there is no place in the code to display the results in termsheet.
0 -
Ok thanks. I didn't understand the use of .subsrcibe. I can see this property calls the sub myRHistoryQuery_OnImage when I put a stop on this sub.
Maybe it's not clear enough in the tutorial.
Many thanks for your help.
Best regards.
0 -
Hi,
Is it possible to include this sub into a loop? I would like to query historical data of many assets with VBA to avoid writing RHistory in my Excel sheets for each. When I create a loop, the first lap works, but on the second one, the ".suscribe" functionality doesn't work and no data can be requested.
Do I need to to put something particular?
Thank you.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 687 Datastream
- 1.4K DSS
- 620 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 254 ETA
- 557 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 276 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 663 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 229 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛