C# casting getMarketDepth()

Please post any questions regarding the program here.

Moderator: 2020vision

C# casting getMarketDepth()

Postby ivars211 » Fri Dec 04, 2015 9:07 pm

Hello everyone,

I have spent whole day today trying to get ba.getMarketDepth() to work properly. From the help it says that the COM interface should be returning an Array of MarketDepthSelection, but it looks like it is not the case. It returns an Object.
Image

When going into Object within debug I can see that it is in fact an Array of MarketDepthSelection inside the Object itself.
Image

The problem is, I cannot seem to find a way to cast that Object into an MarketDepthSelection array.

I have tried the following, but all of them give InvalidCastException:
Code: Select all
Object aa = ba.getMarketDepth();
           
            //aa.GetType();
           
            if (aa != null)
            {
                BettingAssistantCom.Application.MarketDepthSelection[] sections = Array.ConvertAll((BettingAssistantCom.Application.MarketDepthSelection[])aa, s => (MarketDepthSelection)s); // doesn't work
                BettingAssistantCom.Application.MarketDepthSelection[] sections = (BettingAssistantCom.Application.MarketDepthSelection[])aa; // doesn't work
}



I bet there is a some simple solution that I am not aware off and couldn't find on google. I really hope so.

Thank you.
ivars211
 
Posts: 5
Joined: Fri Dec 04, 2015 4:07 pm

Re: C# casting getMarketDepth()

Postby ivars211 » Fri Dec 04, 2015 10:30 pm

Well, that took me only around 7 hours to figure out. Coming from C++ background doesn't help.
The solution that works is to cast it to IEnumerable first and then access it from there, i.e.
Code: Select all
Object aa = ba.getMarketDepth();

if (aa is IEnumerable)
                {
                    IEnumerable myIE = (IEnumerable)aa;
                    foreach(MarketDepthSelection select in myIE)
                    {
                        Debug.WriteLine(select.selection + " "+select.lastPriceMatched);
                    }
                }

Which for some of you would seem obvious, but not for me!
ivars211
 
Posts: 5
Joined: Fri Dec 04, 2015 4:07 pm

Re: C# casting getMarketDepth()

Postby ivars211 » Mon Dec 07, 2015 3:50 pm

Is there any reason why COM ba.getMarketDepth request takes around 250ms on average? Is it just me, or it is so slow by design?
In comparison:
getPrices - 1ms
getAllTradedVolume - 70ms

Thanks
ivars211
 
Posts: 5
Joined: Fri Dec 04, 2015 4:07 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 66 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.