SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Thu Sep 24, 2020 12:13 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Mar 05, 2008 6:06 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
A Strategy has a reference to Portfolio object, which you can use to access Position of any instrument using Portfolio.Positions list of portfolio position.

Code:
if (Portfolio.Positions[instrument] != null)
{
  double qty = Portfolio.Positions[Instrument].Qty;

  ...
}


We will add Portfolio.HasPosition(instrument) in the next release to simplify this code.

Regards,
Anton


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 7:20 pm 
Offline

Joined: Wed Feb 27, 2008 7:37 am
Posts: 28
Anton:
When I use this code, it prints the following

ES 1

for position in Emini S&P. Which is correct, as the account has Long 1 ESH8 but I do not see a designator of Month and Expiration?
What happens if I have the following in IB

Long 1 ESH8
Short 1 ESU8

How will the code handle multiple positions in the same root. I suggest, it should print out

ESH8 1
ESU8 -1

Please check.

Thanx


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 16, 2008 12:56 pm 
Offline

Joined: Thu Mar 20, 2008 4:41 pm
Posts: 273
Location: Sweden
I can't do Portfolio.HasPostion in OnOrderFilled or OnPositionChanged.
Why is that?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 16, 2008 1:38 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Letharion wrote:
I can't do Portfolio.HasPostion in OnOrderFilled or OnPositionChanged.


Why?

Regards,
Anton


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 16, 2008 2:40 pm 
Offline

Joined: Thu Mar 20, 2008 4:41 pm
Posts: 273
Location: Sweden
Dr. Anton Fokin wrote:
Letharion wrote:
I can't do Portfolio.HasPostion in OnOrderFilled or OnPositionChanged.


Why?

Regards,
Anton

Sorry. The portfolio object seems to be out of scope within those functions. I'll post a detailed error message when I get back to the right computer.


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