SmartQuant Discussion
http://www.smartquant.com/forums/

How to access position of a different instrument
http://www.smartquant.com/forums/viewtopic.php?f=64&t=6532
Page 1 of 1

Author:  Dr. Anton Fokin [ Wed Mar 05, 2008 6:06 pm ]
Post subject:  How to access position of a different instrument

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

Author:  csharp_student [ Fri Mar 07, 2008 7:20 pm ]
Post subject: 

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

Author:  Letharion [ Wed Apr 16, 2008 12:56 pm ]
Post subject: 

I can't do Portfolio.HasPostion in OnOrderFilled or OnPositionChanged.
Why is that?

Author:  Dr. Anton Fokin [ Wed Apr 16, 2008 1:38 pm ]
Post subject: 

Letharion wrote:
I can't do Portfolio.HasPostion in OnOrderFilled or OnPositionChanged.


Why?

Regards,
Anton

Author:  Letharion [ Wed Apr 16, 2008 2:40 pm ]
Post subject: 

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.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/