SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue Sep 24, 2019 11:48 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Threads in OpenQuant
PostPosted: Sat Oct 06, 2012 7:28 am 
Offline

Joined: Sat Jan 22, 2011 1:40 am
Posts: 73
I noticed that strategy events such as OnBar(), OnTrade() and order events OnNewOrder(), OnOrderStatusChanged() get triggered in different threads.
For some reason, I see events for one symbol not even on the same thread but on two threads.

My strategy uses multiple symbols and I need to keep a "global" object where I store some parameters. These parameters are used for sorting which orders to execute.

Can someone mention if OnTrade() events are called asynchronously and we need our own locking? And if these are synchronized, why are they on separate threads?

If they are asynchronous - then putting a construct similar to the following should be fine?

Code:
static object globalLock = new object()
public override void OnTrade(Trade trade)
{
    lock (globalLock)
    {
        ... access my global object synchronously
    }
}

Reason I am asking - I am trying to see if this can relate to the IQFeed getting out of memory once every few weeks.
I am trying to see where potentially a deadlock may occur.

Thanks


Top
 Profile  
 
 Post subject: Re: Threads in OpenQuant
PostPosted: Sat Oct 06, 2012 9:52 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
Hi,

are you talking about simulation mode or live trading? There is one (data simulator) thread in the simualtor mode. A number of threads in the live trading mode depends on the data and execution provider (broker API and OQ plugin) design.

Regards,
Anton


Top
 Profile  
 
 Post subject: Re: Threads in OpenQuant
PostPosted: Mon Oct 08, 2012 8:32 am 
Offline

Joined: Sat Jan 22, 2011 1:40 am
Posts: 73
Dr. Anton Fokin wrote:
Hi,

are you talking about simulation mode or live trading? There is one (data simulator) thread in the simualtor mode. A number of threads in the live trading mode depends on the data and execution provider (broker API and OQ plugin) design.

Regards,
Anton


It's a combined question. When I run simulations, I end up commenting out all lock() statements to make sure code runs faster.
However, I use that primarily with a reason of synchronizing code in real-time.

Thanks.


Top
 Profile  
 
 Post subject: Re: Threads in OpenQuant
PostPosted: Mon Oct 08, 2012 10:56 am 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi,

In Paper and Live modes, OnTrade events are almost always executed in different thread from OnBar and 'order' events. But, all OnTrade callbacks are executed in the same thread.

_________________
SmartQuant Development Team


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group