SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sat Sep 19, 2020 5:16 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Apr 07, 2008 4:51 am 
Offline

Joined: Fri Apr 04, 2008 6:11 am
Posts: 138
Assume I'm running a strategy on a collection of instruments...

If I add an instance variable to my strategy, such as in the example below, is the value of that variable shared among the instruments as the strategy executes or local to each instrument?

Code:
public class MyStrategy : Strategy
{
     // vars, want to track separately for each instrument
     double EntryPrice = 0;
     double StopLossPrice = 0;

     ...

     public override void OnTrade(Trade trade)
     {
          if (trade.Price < EntryPrice)  // <--- shared or local?
                ...
     }


I expected it would be shared and that I'd have to create a workaround for it, but it looks like SQ has already done the heavy lifting for us.

(Output from sample run)
SPY entry price = 0
AAPL entry price = 138.25
AAPL entry price = 138.25
AAPL entry price = 138.25
AAPL entry price = 138.25
SPY entry price = 0
SPY entry price = 0
SPY entry price = 0
SPY entry price = 0
AAPL entry price = 138.25
AAPL entry price = 138.25
AAPL entry price = 138.25



I just want to double check this and verify that's what is happening behind the scenes.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 10:20 am 
Offline

Joined: Thu Mar 20, 2008 4:41 pm
Posts: 273
Location: Sweden
The strategy runs separately for each instrument, so the heavy lifting is already done. :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 10:27 am 
Offline

Joined: Fri Apr 04, 2008 6:11 am
Posts: 138
Excellent :D nice work OQ developers!

TradeStation would have left the heavy lifting up to the traders... :evil:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 12:18 pm 
Offline

Joined: Thu Mar 20, 2008 4:41 pm
Posts: 273
Location: Sweden
OnIslandTrader wrote:
Excellent :D nice work OQ developers!

TradeStation would have left the heavy lifting up to the traders... :evil:


I often find myself quite limited by the way TS/EL works, and I'm using OQ for largely for the irritating limitations in EL, but in this case I don't understand the problem?
In any workspace you can have an "arbitrary" number of charts with the same strategy, achieving the same effect.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 8:10 pm 
Offline

Joined: Fri Apr 04, 2008 6:11 am
Posts: 138
Yeah, I was saying that if TS were to offer a solution to running a single instance of a strategy on a collection of stocks (instead of per chart), they'd probably leave the variable swapping up to you instead of coming up with a clean solution the way OQ has.

I was really excited when I saw that OQ had this functionality built in. I thought there was going to be a lot more work for me, but instead they've built a solution the allows me to focus entirely on the strategy itself.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 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