How can I get dividend data and stock splits in C#

Hi, I am currently using the following function to get the OHLC data for a timeseries:

request = timeSeries.SetupDataRequest(ric)
    .WithView("NDA_RAW")
    .WithAllFields()
    .WithInterval(CommonInterval.Daily)
    .WithAdjustedPrice(false)
    .From(dt)
    .OnDataReceived(DataReceivedCallback)
    .CreateAndSend();


I now want to get the dividends and stock splits.

I can do that in excel:

=TR("AAPL.O","TR.DivUnadjustedNet;TR.DivUnadjustedGross","SDate=2010-01-01 EDate=2019-10-24 CH=Fd RH=IN;coraxdividenddate;paymenttype")

or

=TR("AAPL.O","TR.DivUnadjustedNet;TR.DivUnadjustedGross","SDate=2010-01-01 EDate=2019-10-24 CH=Fd RH=IN;coraxdividenddate;paymenttype")


How do I do the same in C#?

Thanks

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @jerome

    To retrieve TR fields with C#, you can use the following APIs:

    1. DEX2 from COM APIs for use in custom applications

    2. Or the GetDataRaw method in NET Libraries for Eikon Data APIs

    For NET Libraries for Eikon Data APIs, the code is:

                eikon = Eikon.CreateDataAPI();
                eikon.SetAppKey("<app key>");
               
                var data = eikon.GetDataRaw(
                   new List<string>
                   {
                        "AAPL.O"
                   },
                   new List<string>
                   {
                        "TR.DivDate",
                        "TR.DivPaymentType",
                        "TR.DivUnadjustedNet",
                        "TR.DivUnadjustedGross"
                   },
                   new Dictionary<string, string>
                   {
                        { "SDate", "2010-01-01" },
                        { "EDate", "2019-10-24" },
                        { "Frq", "D" }
                   });