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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
46 3 5 9

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-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
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

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 5.0 MiB each and 10.0 MiB total.

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

Click below to post an Idea Post Idea