We have an IEnumerable Objects in C# that we want to import into the Wolfram Financial Platform. In the current C# API, we use LINQ queries to select from the Objects the specific Object that we need. In Wolfram Financial Platform we can import the IEnumerable Objects through NET/Link (More info: http://reference.wolfram.com/language/NETLink/tutorial/Overview.html)
Once the object is imported, there does not seem to be a way to use LINQ queries even after importing the LINQ library. Additionally, lambda expressions used in the LINQ queries do not have a clear replacement in Wolfram Financial Platform.
Examples
C#
Object.Where(x => x.Property == Target).FirstOrDefault();
Wolfram
???[# == #.Property &, Object]`FirstOrDefault[];
Current Attempt + Error
C#
Option call = optionChain.Options
.Where(x => (x.Expiration - DateTime.Today).TotalDays > 7 && (x.Expiration - DateTime.Today).TotalDays < 45 && x.PutCall == PutCall.Call && x.Class.Settlement == null)
.OrderBy(x => Math.Abs(msft.Trade.Last - x.Strike)).FirstOrDefault();
Wolfram (baby steps version)
call = optionChain@Options`FirstOrDefault[];
Error
"No public instance method named "FirstOrDefault" exists for the .NET type "Core.Data.MarketData.OptionChain".
Also tried using First[optionChain@Options]; and got the non-atomic error. Found that could mean an infinite loop or non-existent variable. Checked that optionChain@Options exists by outputting it through NETConsole, which makes me think that NETObjects won't work with First[] (?)
End Goal
Import specific values from a C# API with LINQ queries, or equivalent, intact into Wolfram Financial Platform for the purpose of writing a program in the Wolfram Financial Platform language (not allowed to do it the other way around, as much as I want to).
Originally posted this on StackExchange, but it looks like it is pending removal due to being "off-topic"
optionChain@Options
give a Wolfram list of option objects? If so have you triedSelect
? Something likeSelect[DateDifference[#`Expiration - Today, "Day"] > Quantity[7, "Days"] &]@(optionChain@Options)
.Elements of Lists
guide $\endgroup$@ToArray[]
immediately afterOptions
inside of the bracket. This will convert it into a Wolfram list. Then theSelect
should be happy. Well the only part I am unsure about is the#`Expiration
bit. $\endgroup$-
inDateDifference
should be a,
. $\endgroup$