I'm trying to get Corporate Action Data for a company. Everything works as expected until I pass edate/sdate parameters:
.InstrumentIDList = "NORR.OL"
.FieldList = "TR.CAAdjustmentFactor(CAEventType=SCN:SSP:SRE:CRD)"
.RequestParam = "SDate=04/27/2020"
No Error is returned, instead the returned array is an scaler of value NULL
When I leave the Request Parameters empty, I get a scaler value of 100, which is expected.
The corresponding EIKON Excel Formula works when parameters are set.
Function TR(RICs As Variant, Fields As Variant, Params As Variant) Dim strInstrList As String Dim ErrorArray(0, 0) As Variant Dim DataStatus As Dex2Lib.DEX2_DataStatus Application.EnableEvents = True 'Refer to Error Handler On Error GoTo errHandler ErrorArray(0, 0) = " - " 'Tidy Up If Not MyDex2Cookie = 0 Then MyDex2Mgr.Finalize (MyDex2Cookie) MyDex2Cookie = 0 Set MyDex2Mgr = Nothing Set MyDex2RData = Nothing End If ' Create the Dex2 and IDex2 objects. Set MyDex2Mgr = CreateDex2Mgr() Set MyDex2MgrADC = MyDex2Mgr ' Initialise using the DE_MC_ADC_POWERLINK enumeration MyDex2Cookie = MyDex2MgrADC.Initialize(DE_MC_ADC_POWERLINK) ' And create an RData object. Set MyDex2TR = MyDex2Mgr.CreateRData(MyDex2Cookie) ' Make a TR Request Async_UPDT_RCVD = False 'Set recent update to false With MyDex2TR .InstrumentIDList = RICs .FieldList = Fields .RequestParam = Params .Subscribe False End With ' For the With myDex2RData Dim StopTime As Date StopTime = Now() + (1 / 24 / 60 / 60 * 30) Do Until Async_UPDT_RCVD = True Or Now() >= StopTime DoEvents Loop TR = MyDex2TR.Data Exit Function
I don't see inconsistent behavior between =TR function in Excel and RData class of DEX2 COM library. =TR("NORR.OL","TR.CAAdjustmentFactor(CAEventType=SCN:SSP:SRE:CRD)","SDate=20200427") returns NULL just like RData object in your VBA example does. If you have an example where =TR function and RData object return different results given equivalent parameters, please provide both examples: the worksheet function and the VBA code snippet.
When only the SDate parameter is specified, it is interpreted as the request for a single event with announcement date prior to the value of SDate. In the case where there were several events with the same announcement date, all these events will be returned. E.g. =TR("NORR.OL","TR.CAAdjustmentFactor;TR.CAAnnouncementDate;TR.CAEffectiveDate;TR.CAExDate","SDate=20201231 CH=Fd RH:capitalchangeeventid") returns 3 capital change events (with capital change event IDs 73073019917, 73073011444, 73073011468 and announcement date of 2020-12-03).
In your example NORR.OL did not have any capital change events that satisfy capital change event type filters in your request and that were announced prior to 2020-04-27, hence the return value is NULL.
What I suppose you were looking for is the capital change events announced between 2020-04-27 and today. If this is indeed the case, you need to use EDate parameter instead of SDate. =TR("NORR.OL","TR.CAAdjustmentFactor(CAEventType=SCN:SSP:SRE:CRD)","EDate=20200427") returns 100. It is interpreted as a request for all capital change events that satisfy event type filters that were announced between the values of EDate and SDate, i.e. between 2020-04-27 and today's date (the default value of SDate is "0D" or today). There was only one such event (event ID 73073011444 announced on 2020-12-03), and the value of TR.CAAdjustmentFactor for this event is 100.