SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Dec 13, 2017 2:52 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Jun 16, 2014 12:10 pm 
Offline

Joined: Wed Jun 11, 2014 11:05 am
Posts: 2
I know if I want to do multi-instrument strategy, I should put my strategy in onBarSlice event,
but onBarSlice will trigger N times in the same time, if I put N instruments in project,
how should i do to make it trigger only one time in the same time?


Top
 Profile  
 
PostPosted: Mon Jun 16, 2014 12:25 pm 
Offline

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

do you want to execute your strategy logic for every instrument (i.e. you actually want to have N copies of your strategy, one copy for one instrument, running in parallel), or you want to do something else, like execute once for all instruments?

Regards,
Anton


Top
 Profile  
 
PostPosted: Tue Jun 17, 2014 5:29 am 
Offline

Joined: Wed Jun 11, 2014 11:05 am
Posts: 2
Hi, Anton

I mean if the "onBarSlice" triggerd N times,
it will make me send N orders at the same instruments,

In this example, if the logic is true,
it will send 2 buyorder in DELL(BarSlice at DELL & BarSlice at APPL),
and send 2 sellorder in APPL(BarSlice at DELL & BarSlice at APPL),

Can I get only one BarSlice event when all instruments slice?

Code:
public override void OnBarSlice(long size)
   {
      double biasDELL=0;
      double biasAPPL=0;
      
      try
      {
         biasDELL=(barDELL.Last.Close-smaDELL.Last)/smaDELL.Last;
         biasAPPL=(barAPPL.Last.Close-smaAPPL.Last)/smaAPPL.Last;   
      }
      catch{}
      
      if (biasDELL>biasAPPL)
      {
         Long(sDELL);Short(sAPPL);
      }
      else
      {
         Long(sAPPL);Short(sDELL);
      }   
   }


Top
 Profile  
 
PostPosted: Tue Jun 17, 2014 6:48 pm 
Offline

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

indeed OnBarSlice will be triggered only once for one instrument, but since you send two orders for both DELL and AAPL in OnBarSlice event handler, your strategy will send two orders in DELL OnBarSlice handler and two orders in AAPL handler. I guess this is not what you want to do. A simple way to resolve this is to do something like

public override void OnBarSlice(long size)
{
if (Instrument != InstrumentManager.Instruments["AAPL"])
return;

...

}

so that your orders will be sent in AAPL OnBarSlice only.

Regards,
Anton


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 3 guests


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