Back

Hedging

Hi there,

I am currently porting some of my projects from cTrader to lean and so far its going well.

Except that my most promising project uses hedging. I know that its probably not on your timeline as stated here 

https://www.quantconnect.com/forum/discussion/2104/hedging-vs-netting-account/p1/comment-6403

I am willing to have a look at providing some implementation for that, but could use some pointers.
Where would I start? I could probably drop something in there that uses specific symbols or drop a field in the symbol class that identifies the position and then look at that field in the brokerage somewhere. But i would prefer a more general way that has a chance to work with backtesting.

Any thoughts?

Update Backtest







When you say "hedging", what exactly do you mean?

If you mean simply holding offsetting positions in other, correlated assets then that's of course something you can do.

Maybe there's a way to take the mechanics of what you need and turn them into something that works with the current functionality of QuantConnect?

0

I need to hold long and short positions in one asset at the same time.
When I use a hedging account with LEAN it will open a new position in the opposite direction when I use Liquidate().
Currently I am trying to add a new method that takes a symbol parameter and a long/short enum and actually closes all positions that match the parameters. I think that should work with my brokerage, but I have no clue how to support that in backtesting.

0

Hey Mirco! Thank you for the offer. It is a lot of work but if you're up for it we can help guide the design! =)

Positions would need to be recorded separately instead of being placed into a single decimal Quantity field. This would need some sort of array of Position objects stored in the security. The positions would need to be referenced somehow so we could flag them as closed. Perhaps when people place orders they can flag which position they'd like them to apply against. 

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed