question

Upvotes
Accepted

DEX 2 Requst on TR.CAAdjustmentFactor Is NULL when Sdate ist set as a parameter

Hi,

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
eikoneikon-com-apidata
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvote
Accepted
39.2k 75 11 27

@konstantin.hammerschmidt

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.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

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.

You are right of course. What got me confused is that start and end date are backward looking, ie. SDate=recent, EDate=old. It does make sense, now that you told me SDate=0D by default.

There is some inconsistency vs the TR function however. I guess that is because the frontend adjusts for my mixup, hence I didn't notice that mistake earlier....:

=TR(E15,"TR.CAAdjustmentFactor(CAEventType=SCN:SCO:SSP:SDI:SIS:DIV)","SDate=04/27/2020 EDate=12/22/2020")

This Excel Formula will return 100, although the dates are turned around.....

Alex Putkov.1 avatar image Alex Putkov.1 konstantin.hammerschmidt

When you explicitly specify both SDate and EDate, the request returns the events announced between the values of SDate and EDate. The order of SDate and EDate (i.e. whether SDate is nearest and EDate is farthest or vice versa) determines the order of the results; i.e. it determines whether the events are returned in chronological (the most recent event last) or reverse chronological (the most recent event first) order. In all cases the behavior is consistent between =TR worksheet function and RData COM object.

Click below to post an Idea Post Idea