API Support Forum
OEC API > API Support > How to get est API performance
Author Topic: How to get est API performance
(2 messages, Page 1 of 1)
Moderators: VPfau
BBrandon
Posts: 24
Joined: Dec 08, 2010


Posted: Mar 03, 2011 @ 10:25 AM             Msg. 1 of 2
Hi,

I am wondering which is the best way to write efficent API code since I want to monitor several contracts on a tick by tick basis.

Currently I work with console applications which I remote to the OEC trader platform. I choose to remote as during development I can better manage the trades that way. However I can do without it later. My questions is:

1) does remoting vs stand alone greatly impact performace ?
2) what is more efficient API program, console vs gui-light winform ?

The second question is related to how the API manages and triggers events. As I will be dealing with multiple assets which might have concurrent firings I wanted to keep things resource light. However I noticed that the API events are synchronous, or at least fire, in the same thread as my console application. If I need to use these to execute my code asynchronoulsy I would like to do so in the most compatible manner with the API. Currently I am thinking of just manually executing my code with beginInvoke's or as new threads.

Any comments would be welcome

thanks,

Brandon

Brandon
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Mar 03, 2011 @ 11:07 AM             Msg. 2 of 2
Hello,

because of nature of .NET remoting, standalone applications are better for performance. But real impact depends on volume of subscribed data, ping to our server and hardware: the cost of remoting can be significantly less than network lag between exchange and your application.

Console application by default is better for performance. But actually it depends on your implementation of WinForm application: how to split threads for GUI, OECAPI and business logic, how to show data and, again, volume of subscribed data and hardware.

OECAPI calls all events in the thread that created it and has a Windows message pump. This is why it is better to use separate threads for GUI and OECAPI to reduce lagging.
Methods of OECAPI are not thread-safe. You need to sync access to API from several threads. And you're right, BeginInvoke method of any window or control that created in the same thread as OECAPI is a good way to do it. As an alternative, you can use SynchronizationContext.