SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Thu Sep 19, 2019 8:22 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: Thu Aug 02, 2007 3:00 am 
Offline

Joined: Thu Aug 02, 2007 2:47 am
Posts: 17
Does anyone have an example of a spread strategy? ie creating a ratio/spread between 2 securities and then firing off orders on both securities based on thresholds of the ratio? wud be a great help. thnks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 7:59 am 
Offline

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

take a look at this thread

http://www.smartquant.com/forums/viewto ... ght=spread

Regards,
Anton


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 3:18 pm 
Offline

Joined: Thu Mar 16, 2006 12:15 pm
Posts: 184
I think ther once was an example with stocks listed on different exchanges or was it forex? Could you provide this one again?

_________________
Expect the unexpected. May your MM/RM be with you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 3:56 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
I think it's one of FOREX strategies from TickJob discussed in the Strategies section of this forum.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 4:27 pm 
Offline

Joined: Thu Mar 16, 2006 12:15 pm
Posts: 184
I dont think so. It was an example strategy on your homepage as I remeber - maybe 1-2 years ago.

_________________
Expect the unexpected. May your MM/RM be with you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 4:36 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
I think it was a kind of correlation pair trading strategy, but it was for QuantStudio, predecessor of QuantDeveloper and OpenQuant (backtesting only).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 4:39 pm 
Offline

Joined: Thu Mar 16, 2006 12:15 pm
Posts: 184
I think you are right. It would be helpful to have an example of this kind of system.

_________________
Expect the unexpected. May your MM/RM be with you.


Top
 Profile  
 
PostPosted: Thu Aug 02, 2007 5:16 pm 
Offline

Joined: Thu Aug 02, 2007 2:47 am
Posts: 17
hi Anton...i have looked at the link u referred me to but i was wondering if you have an example of firing off 2 simultaneous orders (at least the way you would do it).....there are lots of references to spread strategies in docs but cant find solid example (full strategy) of buying and selling a pair of securities..it wud be extremely helpful as any mismatch in logic cud really throw the timing off..thnks again


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 7:39 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
Something like this?

Code:
public class MyStrategy : Strategy
{
   Instrument DELL;
   Instrument CSCO;
   
   TimeSeries spread;
   
   public override void OnStrategyStart()
   {
      DELL = Instruments["DELL"];
      CSCO = Instruments["CSCO"];
       
      spread = new TimeSeries("DELL - CSCO", Color.Pink);
       
      SMA SMA = new SMA(spread, 14, Color.Blue);
       
      Draw(spread, 2);
      Draw(SMA, 2);
   }

   public override void OnBarSlice(long size)
   {
      if (Instrument == CSCO)
      {
         spread = CSCO.Bar.Close / DELL.Bar.Close;

         spread.Add(CSCO.Bar.DateTime, spread);

         if (spread > 0.1)
         {
            Buy(CSCO, 100);
            Sell(Dell, 100);
         }
      }
   }
}


Top
 Profile  
 
PostPosted: Thu Aug 02, 2007 8:05 pm 
Offline

Joined: Thu Aug 02, 2007 2:47 am
Posts: 17
i copy/pasted and tried running using CSCO and DELL daily data already included with initial download and got following errors?

Cannot implicitly convert type 'double' to 'OpenQuant.API.TimeSeries'

The best overloaded method match for "OpenQuant.API.TimeSeries.Add (Sytem.DateTime,double' has some invalid aruguments

Argument '2':cannot convert from 'OpenQuant.API.TimeSeries 'to 'double'

Operator '>' cannot be applied to operands of type 'OpenQuant.API.TimeSeries' and 'double'

The name 'Dell' does not exist in the current context


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 9:22 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
Code:
public class MyStrategy : Strategy
{
   Instrument DELL;
   Instrument CSCO;
   
   TimeSeries spread;
   
   public override void OnStrategyStart()
   {
      DELL = Instruments["DELL"];
      CSCO = Instruments["CSCO"];
       
      spread_series = new TimeSeries("DELL - CSCO", Color.Pink);
       
      SMA SMA = new SMA(spread_series, 14, Color.Blue);
       
      Draw(spread_series, 2);
      Draw(SMA, 2);
   }

   public override void OnBarSlice(long size)
   {
      if (Instrument == CSCO)
      {
         spread = CSCO.Bar.Close / DELL.Bar.Close;

         spread_series.Add(CSCO.Bar.DateTime, spread);

         if (spread > 0.1)
         {
            Buy(CSCO, 100);
            Sell(Dell, 100);
         }
      }
   }
}


Top
 Profile  
 
PostPosted: Thu Aug 02, 2007 9:44 pm 
Offline

Joined: Thu Aug 02, 2007 2:47 am
Posts: 17
still getting errors. all the other strategy examples work great and i can tweak them to get what i want but i would love a working spread strategy example (entry & exit). if anyone out there has good example that enters and exits based on the spread of any 2 securities please post!! thanks!

errors?:
The name 'spread_series' does not exist in current context

Cannot implicitly convert type 'double' to 'OpenQuant.API.TimeSeries'

Operator '>' cannot be applied to operands of type 'OpenQuant.API.TimeSeries' and 'double'

The name 'Dell' does not exist in the current context


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 11:47 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
Well, I am writing this from my head, since I thought you want to get the idea of spread trading with OpenQuant, not just a code sample to copypaste. Could you look through the code? The errors are more or less obvious

TimeSeries spread;

should be changed to

TimeSeries spread_series;

spread variable should be defined

double spread = CSCO.Bar.Close / DELL.Bar.Close;

and then Dell should be in capital letters

Sell(DELL, 100);

That's it. Just syntax errors...

Code:
public class MyStrategy : Strategy
{
   Instrument DELL;
   Instrument CSCO;
   
   TimeSeries spread_series;
   
   public override void OnStrategyStart()
   {
      DELL = Instruments["DELL"];
      CSCO = Instruments["CSCO"];
       
      spread_series = new TimeSeries("DELL - CSCO", Color.Pink);
       
      SMA SMA = new SMA(spread_series, 14, Color.Blue);
       
      Draw(spread_series, 2);
      Draw(SMA, 2);
   }

   public override void OnBarSlice(long size)
   {
      if (Instrument == CSCO)
      {
         double spread = CSCO.Bar.Close / DELL.Bar.Close;

         spread_series.Add(CSCO.Bar.DateTime, spread);

         if (spread > 0.1)
         {
            Buy(CSCO, 100);
            Sell(DELL, 100);
         }
      }
   }
}


Top
 Profile  
 
 Post subject: awesome
PostPosted: Fri Aug 03, 2007 12:26 am 
Offline

Joined: Thu Aug 02, 2007 2:47 am
Posts: 17
thanks for the quick responses Anton. I've been using your system for all of 2 days so I'm still trying to get a handle. great product as there is a large gap between low end retail systems and high end ones (which quite honestly many of them are overrated). i just wish there was better documentation with more details to walk me through a lot more features and examples. we are a small hedgefund looking to automate our models and this looks like a great product to get started with so we can grow into your other products. thanks again


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 03, 2007 9:42 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
FYI. OpenQuant offers only one strategy development model and QuantDeveloper has something like four different models. One of them is dedicated to cross-market / correlation type of strategies and it's described in QuantDeveloper manual (together with strategy code samples).

Once you are comfortable with OpenQuant, I suggest you talk to QuantHouse to see if their product suite can help you trading more complex strategies.

Regards,
Anton


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next

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