July 12th, 2005, 4:17 pm
You could use the Reuters DEX API to retrieve the TIC data and use the objects update event. You may need to change the service but the default is usually IDN. (see attached).VBA:' Tools, References, to DEX 1.0 Type Library.Private WithEvents DexInstrument As DEXLib.MrvInstrumentPrivate iRIC As Integer'Sub called from buttonPublic Sub Initialise() Me.Range("OutputRange").Clear iRIC = 0 GetIntraDayData (iRIC)End SubPrivate Sub GetIntraDayData(ByVal iRICNumber As Integer) Dim strDate As String Dim strEnd As String Dim strRIC As String Dim strRange As String Dim strStart As String On Error GoTo ErrHandler strRIC = Me.Range("RIC1").Offset(iRICNumber, 0).Value If VBA.Len(strRIC) = 0 Then Exit Sub ' Finished List End If If DexInstrument Is Nothing Then Set DexInstrument = New DEXLib.MrvInstrument strStart = VBA.Format(Me.Range("Start").Value, "HH:MM") strEnd = VBA.Format(Me.Range("End").Value, "HH:MM") strDate = VBA.Format(VBA.Date, "DD/MMM/YYYY") strRange = "START:" & strDate & "-" & strStart & " END:" & strDate & "-" & strEnd With DexInstrument .ErrorMode = EXCEPTION .IDType = "RIC" .InstrumentID = strRIC .Mode = "SOURCEBU HEADER:YES LAY:HOR" .RequestTimeSeries "LAST TRADE", Array("VALUE", "VOLUME", "FILTER_CODE1", "FILTER_CODE2", _ "FILTER_CODE3", "FILTER_CODE4"), _ strRange & " SERVICE:IDN INTERVAL:TAS" End WithFinish: Exit SubErrHandler:Debug.Print "GetIntraDayData: " & DexInstrument.ErrorString & " " & DexInstrument.RunStatus & " " & VBA.NowDebug.Print "GetIntraDayData: " & Err.Description & " " & VBA.NowGoTo FinishEnd SubPrivate Sub DexInstrument_OnUpdate(ByVal DataStatus As DEXLib.DE_DataStatus)Dim dTotVal As DoubleDim dTotVol As DoubleDim dVWAP As DoubleDim i As IntegerDim vResult As VariantOn Error GoTo ErrHandler vResult = DexInstrument.Data 'If DataStatus = 1 Then If IsEmpty(vResult) Then Me.Range("RIC1").Offset(iRIC, 2).Value = "No Data on DBU" Else For i = LBound(vResult, 1) + 1 To UBound(vResult, 1) dTotVal = dTotVal + vResult(i, 1) * vResult(i, 2) dTotVol = dTotVol + vResult(i, 2) Next i If dTotVal = 0 And dTotVol = 0 Then dVWAP = 0 Else dVWAP = dTotVal / dTotVol With Me.Range("RIC1") .Offset(iRIC, 2).Value = VBA.Format(dVWAP, "0.00##") .Offset(iRIC, 3).Value = VBA.Format(dTotVol, "#,###") .Offset(iRIC, 4).Value = VBA.Format(VBA.Time, "HH:MM:SS") End With End IfFinish:Set DexInstrument = NothingiRIC = iRIC + 1GetIntraDayData iRICExit SubErrHandler:Debug.Print "GetIntraDayData_Update: " & DexInstrument.ErrorString & " " & DexInstrument.RunStatus & " " & VBA.NowDebug.Print "GetIntraDayData_Update: " & Err.Description & " " & VBA.NowGoTo FinishEnd Sub
-
Attachments
-
DEX Reuters API RIC.zip
- (18.73 KiB) Downloaded 72 times