SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Aug 15, 2018 3:49 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Portfolio.Positions.Item
PostPosted: Sun Nov 09, 2008 6:55 pm 
Offline

Joined: Wed Nov 05, 2008 1:32 am
Posts: 4
When I tried to compile my code:

....

Position myPosition;
myInstr = Instruments["QQQQ"]

myPosition = Portfolio.Positions.Item( myInstr ):

....

I kept getting the following error:

'OpenQuant.API.PositionList' does not contain a defination for 'Item' and no extension method 'Item' accepting a first argument of type 'OpenQuant.API.PositionList' could be found (are you missing a using directive or an assembly reference?)

However, the syntax seems to be correct according to the OpenQuant API Documentation:

PositionList.Item Property

Public Properties
Item (Instrument) Returns position by instrument.

======

Any help will be appreciated.

M.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 12:33 pm 
Offline
Site Admin

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

The correct syntax (C#) is

myPosition = Portfolio.Positions[myInstr];

The line myPosition = Portfolio.Positions.Item( myInstr ) applies to VB syntax.

Regards,
Alex

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 11:12 pm 
Offline

Joined: Wed Nov 05, 2008 1:32 am
Posts: 4
Thx a lot Alex.

Alexei Kurov wrote:
Hi,

The correct syntax (C#) is

myPosition = Portfolio.Positions[myInstr];

The line myPosition = Portfolio.Positions.Item( myInstr ) applies to VB syntax.

Regards,
Alex


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2008 12:16 am 
Offline

Joined: Mon Nov 24, 2008 8:44 pm
Posts: 36
For this example:

Position myPosition;
myInstr = Instruments["QQQQ"]
myPosition = Portfolio.Positions[myInstr];
...

If I had added to my position for the same instrument multiple times...how do I find the latest transaction? Basically I am looking to exit my position for a particular instrument one transaction at a time...can that be done?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2008 11:53 am 
Offline

Joined: Wed Oct 08, 2003 1:06 pm
Posts: 833
Hi,

You can use the following code to find the latest transaction of a position:

Code:

Position position = Portfolio.Positions[myInstrument];

Transaction transaction = position.Transactions[position.Transactions.Count - 1];

Quote:
Basically I am looking to exit my position for a particular instrument one transaction at a time...can that be done?


Your logic is fine: find the latest transaction using the sample above and use its Qty property to but/sell required quantity.

Regards,
Sergey.


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