Dex2 Sample - Create RData request C# to get "TR.CLOSE" or "CF_CLOSE" do not work
I am using the Dex2 sample (CSharpEikonnect). I have Eikon desktop version 4.0.36 running and no problems with steps 1 to 4 (Connecting to Eikon, Creating Dex2 Manager, Creating RData request…). In step 4 Request the Data does not work properly. What other commands I could use? I had a look at the Data Item Browser, but none of the commands there does return any results. Am I missing something? What I would like to do is to replicate the following:
privatevoid CreateRData(string InstrumentIDList,
string FieldList,
string RequestParam,
string DisplayParam)
{
// Create a RData
MyRData = MyDex2Mgr.CreateRData(MyDex2Cookie);
MyRData.OnUpdate += OnUpdate;
// Initialize the RData to request
if (MyRData != null)
{
MyRData.InstrumentIDList = InstrumentIDList; // “AAPL.O”
MyRData.FieldList = FieldList; // “TR.CLOSE” or “CF_CLOSE” or “CF_LAST”
MyRData.RequestParam = RequestParam; // “edate: -20d sdate: -9d”
MyRData.DisplayParam = DisplayParam; // “RH:In CH:Fd”
}
}
Thank you.
Best Answer
-
For reference data, you can reference DEX2.dll and EikonDesktopDataAPI.dll and use the following sample. The way to set up the call is different for these so called 'ADC' calls, where the fields are identified with TR.something. You will notice the mDexCookieADC.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EikonDesktopDataAPI;
using Dex2;
namespace DEX2ADC
{
class Program
{
//******************************************************************************
// class variables
//
EikonDesktopDataAPI.EikonDesktopDataAPI sdk;
Dex2.Dex2Mgr d2m;
Dex2.RData rdta;
int mDexCookieADC;
public Program()
{
mDexCookieADC = 0;
//******************************************************************************
// Create EikonDesktopDataAPI object and connect to its outgoing interface
//
sdk = new EikonDesktopDataAPI.EikonDesktopDataAPI();
if (sdk != null)
{
EikonDesktopDataAPI.EEikonDataAPIInitializeResult l_result = sdk.Initialize();
if (l_result != EikonDesktopDataAPI.EEikonDataAPIInitializeResult.Succeed)
{
//Error Handling
}
//Add a handler to OnStatusChanged event
}
sdk.OnStatusChanged += OnStatusChanged;
Console.ReadLine();//stop the command window closing and the program ending
}//main end
//******************************************************************************
// what to do when the user logs on to Eikon
//
public void OnStatusChanged(EEikonStatus EStatus)
{
switch (EStatus)
{
case EEikonStatus.Connected://Eikon is now connected so we can start making the API call
CreateDex2Mgr();
//CreateRData("594918AY0=;36962G4J0=", "TR.IssuerRating;TR.GR.Rating", "", "RH:In CH:fd");
//CreateRData(".FTSE", "TR.IndexConstituentRIC;TR.IndexConstituentWeightPercent", "", "CH:fd");
CreateRData("NVDA.O", "TR.PRICEAVG100D;TR.PriceNetChg1D;TR.PriceMoRegionRank;TR.RSISimple14D;TR.CompanyName;TR.TRBCEconomicSector;TR.CreditComboRegionRank", "", "CH:fd");
break;
case EEikonStatus.Disconnected:
break;
case EEikonStatus.Offline:
break;
}
}
//******************************************************************************
// Create dex manager
//
private void CreateDex2Mgr()
{
d2m = sdk.CreateDex2Mgr();
var d2mADC = (IDex2Mgr2) d2m;
if (d2mADC != null)
{
mDexCookieADC = d2mADC.Initialize(DEX2_MetadataCaller.DE_MC_ADC_POWERLINK);
}
}
//******************************************************************************
// Create RData object
//
private void CreateRData(string instrumentIdList, string fieldList, string requestParam, string displayParam)
{
rdta = d2m.CreateRData(mDexCookieADC);
rdta.OnUpdate += OnUpdate;
if (rdta != null)
{
rdta.InstrumentIDList = instrumentIdList;
rdta.FieldList = fieldList;
rdta.RequestParam = requestParam;
rdta.DisplayParam = displayParam;
rdta.Subscribe();
}
}
//******************************************************************************
// Data retrieved call back
//
public void OnUpdate(Dex2.DEX2_DataStatus dataStatus, object error)
{
switch (dataStatus)
{
case DEX2_DataStatus.DE_DS_FULL:
long i = 0;
long j = 0;
Array l_response = rdta.Data as Array;
for (i = l_response.GetLowerBound(0); i <= l_response.GetUpperBound(0); ++i)
{
long l_row;
l_row = i - l_response.GetLowerBound(0) + 1;
for (j = l_response.GetLowerBound(1); j <= l_response.GetUpperBound(1); ++j)
{
// error handling could be done here
Console.WriteLine(" " + rdta.Data[i, j]);
}
Console.WriteLine(Environment.NewLine);
}
break;
case DEX2_DataStatus.DE_DS_NULL_EMPTY:
if (error != null)
Console.WriteLine("Error : " + error);
else
Console.WriteLine("Error : DE_DS_NULL_EMPTY");
break;
case DEX2_DataStatus.DE_DS_NULL_ERROR:
if (error != null)
Console.WriteLine("Error : " + error);
else
Console.WriteLine("Error : DE_DS_NULL_ERROR");
break;
case DEX2_DataStatus.DE_DS_NULL_TIMEOUT:
if (error != null)
Console.WriteLine("Error : " + error);
else
Console.WriteLine("Error : DE_DS_NULL_TIMEOUT");
break;
case DEX2_DataStatus.DE_DS_PARTIAL:
if (error != null)
Console.WriteLine("Error : " + error);
else
Console.WriteLine("Error : DE_DS_PARTIAL");
break;
}
}
static void Main(string[] args)
{
Program prog = new Program();
}
}//class end
}// namespace end0
Answers
-
From the code, I assume that you would like to retrieve the daily historical data of CLOSE field.
You can use .NET APIs to retrieve this information. Please refer to:
The snippet code is:
tsDataRequest = timeSeries.SetupDataRequest("AAPL.O")
.WithAllFields()
.WithInterval(CommonInterval.Daily)
.From(DateTime.Now.AddDays(-20))
.To(DateTime.Now.AddDays(-9))
.OnDataReceived(OnTSReceived).CreateAndSend();
private void OnTSReceived(DataChunk chuck)
{
Console.WriteLine("OnTSRecieved {0}", chuck.IsLast);
foreach (IData record in chuck.Records)
{
foreach (var sample in record)
{
Console.WriteLine("{0} {1}", sample.Key, sample.Value);
}
Console.WriteLine();
}
}The output looks like:
HIGH 106
CLOSE 105.87
LOW 105.28
OPEN 105.58
VOLUME 27408650
TIMESTAMP 8/4/2016 12:00:00 AM
COUNT 147500
HIGH 107.65
CLOSE 107.48
LOW 106.18
OPEN 106.27
VOLUME 40553402
TIMESTAMP 8/5/2016 12:00:00 AM
COUNT 182161
HIGH 108.37
CLOSE 108.37
LOW 107.16
OPEN 107.52
VOLUME 28037220
TIMESTAMP 8/8/2016 12:00:00 AM
COUNT 143108
...You may also refer to this question.
0 -
Hi and thank you for the reply. I am already using the .NET as you suggested and that is great.! I would like to replicated some of the functions available in Office API like:
=TR("NVDA.O", "TR.PRICEAVG100D")
=TR("NVDA.O","TR.PriceNetChg1D")
=TR("NVDA.O","TR.PriceMoRegionRank")
=TR("NVDA.O","TR.RSISimple14D ")
=TR("NVDA.O","TR.CompanyName")
=TR("NVDA.O","TR.TRBCEconomicSector")
=TR("NVDA.O", "TR.CreditComboRegionRank")
Is that possible with the .NET API? According to the documentation that is available in the DEX2 API.
0 -
That was exactly what I was looking for! Thank you!
0 -
Any chance someone could translate this to R?
I am particularly interested in getting the following to work:
=RSearch("FUND",A2:B3,"NBROWS:2000",,C2)
(A2:B3 are search parameters, RCSAssetCategoryGenealogy and RCSIssuerDomicileCountry)
=TR($C2,"TR.FundRollingPerformance(RollTimeFrame=SI Interval=M).value","Transpose=Y NULL=NULL",M2)
=TR($C2,"TR.FundNAV(Align=ME).value","EDate=1D SDate=1980-01-01 Transpose=Y NULL=NULL",F2)
=TR($C2,"TR.FundType")
=TR($C2," TR.PrimaryIssueRICCode")
=TR($C2,"TR.FundBenchmarkInstrumentCode")
Any help would be greatly appreciated.
0
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛