SetShareSize when trading multiple assets
Author: dan_rozenberg
Creation Date: 10/31/2017 2:16 PM
profile picture

dan_rozenberg

#1
Hi. I have a strategy running in a portfolio that for each asset, in the end of each day, it adjust a hedge position. It checks if the PositionType of "position" and "hedge position" are different and, if it is, it closes the old hedge position and opens a new hedge position. However the number of shares should be different for the position and hedge position. I'm trying the following:

CODE:
Please log in to see this code.


hedgeBars is the Bars object of the hedge asset, hedgePos is the Position object of the hedge position, pos is the Position object of the position and lote is the share size of pos.

However when running it, both position and hedge position are getting the same number of shares. Someone could help me?
profile picture

KGo

#2
Because context is set to hedgeBars both price are the same in
CODE:
Please log in to see this code.
profile picture

dan_rozenberg

#3
Thank you.
profile picture

Eugene

#4
Expanding on KGo's reply, you probably wanted to code it like this:
CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).