Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
46 4 6 10

Can't perform mathematical operations on data obtained from .NET Real-time data API in Visual Studio

Hello,

Sorry in advance for the triviality of this question (as I know it is related to the C# language structure) but I've been googling like crazy and couldn't find an answer.. so here it goes:

When I retrieve economic indicators' data through the .NET Real-time data API, this data comes in as object type. However, I would like to perform simple mathematical operations on this data (substractions, multiplications..) but keep getting the error "Operator '-' cannot be applied to operands of type 'object' and 'object'" when I try to.

I tried converting the obtained data from object type to other types allowing calculations (like int, float etc..) but the console simply stops responding when that part of the code comes up: I get no result, just an eternal wait.

Could you help me ??

Thanks for your time!

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api
icon clock
10 |1500

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

1 Answer

· Write an Answer
Upvote
Accepted
39.4k 77 11 27

When you get FieldValue object you can use ToDecimal or ToDouble methods to convert the value to System.Decimal or System.Double. If field value may be null use ToNullableDecimal or ToNullableDouble to convert the value to System.Decimal? or System.Double?. E.g. fieldUpdate.Value.ToDouble()

icon clock
10 |1500

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

This is great! Indeed using the ToNullable... method was the answer! Thanks a lot !!

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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