EMA C#: OmmDate object modified during the for-each iteration
Real-Time: For Real-Time SDK C#, looks like the OmmDate object will be modified during the for-each iteration, could you please verify if this is a bug? Take this RIC as example /HCEIX4 .
public void OnRefreshMsg(RefreshMsg refreshMsg, IOmmConsumerEvent consumerEvent)
{
OmmDate? date = null;
Console.WriteLine(refreshMsg);
foreach (var field in refreshMsg.Payload().FieldList())
{
if (field.Code == Data.DataCode.BLANK)
continue;
switch (field.FieldId){
case 16:
date = field.OmmDateValue();
Console.WriteLine($"date (in-place): {date}");
break;
}
}
Console.WriteLine($"date (after-foreach): {date}");
}
This function is used to extract one specific field with fieldId == 16 (i.e., TRADE_DATE) into my date object. The output I get is this:
date (in-place): 29 OCT 2024
date (after-foreach): (blank data)
Best Answer
-
Hello @Frederic
I found the client has submitted the GitHub issue 291 to the RTSDK team. The RTSDK team has investigated the issue, and the team confirms that it is by the design of the API, not a bug.
RTSDK Team comment:
For performance reasons RTSDK EMA Library reuses objects whenever possible. That's why objects returned from data access methods are transient and short-lived. Values that they contain are not guaranteed to live outside of scope.
In the case described above it is application's responsibility to copy data its needs from the object returned by the
OmmDateValue()
method.Example Code:
Each application might have different business requirement, so there is no universal solution to copy data out of the FieldEntry.OmmXXValue() methods that fits all purposes.
There are various ways to copy data such as using .NET DateOny object or string, etc. as follows:
DateOny object (available on .NET 6 and .NET 8)
DateOnly date = DateOnly.FromDateTime(DateTime.Now);
Console.WriteLine(refreshMsg);
foreach (var field in refreshMsg.Payload().FieldList())
{
if (field.Code == Data.DataCode.BLANK)
continue;
switch (field.FieldId)
{
case 16:
//date = field.OmmDateValue().ToString();
date = new DateOnly(field.OmmDateValue().Year,
field.OmmDateValue().Month,
field.OmmDateValue().Day);
Console.WriteLine($"date (in-place): {date.ToString("dd MMM yyyy")}");
break;
}
}
Console.WriteLine($"date (after-foreach): {date.ToString("dd MMM yyyy")}");String:
string date = "";
Console.WriteLine(refreshMsg);
foreach (var field in refreshMsg.Payload().FieldList())
{
if (field.Code == Data.DataCode.BLANK)
continue;
switch (field.FieldId)
{
case 16:
date = field.OmmDateValue().ToString();
Console.WriteLine($"date (in-place): {date.ToString()}");
break;
}
}
Console.WriteLine($"date (after-foreach): {date}");0
Answers
-
Hello @Frederic
I can replicate the issue with the EMA C# 3.3.0 (RTSDK C# 2.2.2.L1), .NET 8.0 with the given code and RIC. This issue should be investigated by the RDC team.
Result from the given code:
INFO|: loggerMsg
ClientName: ChannelCallbackClient
Severity: Info Text: Received ChannelUp event on channel Channel_1
Instance Name Consumer_1_1
Component Version ads3.7.3.L1.linux.rrg 64-bit
loggerMsgEnd
RefreshMsg
streamId="5"
domain="MarketPrice Domain"
name="/HCEIX4"
serviceName="ELEKTRON_DD"
Payload dataType="FieldList"
FieldList FieldListNum="20" DictionaryId="1"
...
FieldEntry fid="16" name="TRADE_DATE" dataType="Date" value=" 5 NOV 2024 "
...
FieldListEnd
PayloadEnd
RefreshMsgEnd
date (in-place): 5 NOV 2024
date (after-foreach): (blank data)Are you post this question on behalf of the client? If so, there are 2 ways to process the issue further.
## If the client is the RDC named user ##
If the client is the RDC named user, the client can submit a support ticket to the Real-Time APIs support team (RDC team). The client can submit a support ticket by login to the Developer Portal website with their company email account and click the "Contact Premium Support" button on the https://developers.lseg.com/en/api-catalog/real-time/robust-foundation-api-raf-net page.
Then, choose the RTSDK ETA C# on the product category:
Note: There is a bug on the RTSDK C# page that makes the "contact premium support" button from the RTSDK page, so I suggest the client submit a support ticket via the RFA page instead.
## If the client is not the RDC named user ##
If the client is not the RDC named user, the client can submit the issue to the RTSDK team via the GitHub Issue page directly.
I hope this information helps.
0 -
Hi @wasin.w
I am the user the reported the issue in the first place. I made a comment to this github issue: https://github.com/Refinitiv/Real-Time-SDK/issues/291#issuecomment-2463687755
For sure there are ways to circumvent this quirk, but i am sure such behavior must surprise most (if not) all C# programmer--"modern" languages like C#/Java are designed to let programmers avoid the headache of C++ (and they pay the price of extra overheads of GC). Now the SDK brings it back, and worst--it brings it back without telling us so...
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 249 ETA
- 554 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 643 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 192 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛