Is there a way to calculate the expected fees for an order?
I'd like to estimate the risk-worthiness of an options spread before i open the position. To do so, i need to run some risk-reward calculations, and factor in the cost of executing the order (ie: the order fees that will be incurred).
How can I determine the expected order fees, before an order is placed? Does the LEAN API expose this somewhere?
Derek Melchin
Hi .ekz.,
To get the fees involved with placing an order, we can use the `GetOrderFee` method.
See the attached backtest for reference.
Best,
Derek Melchin
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.
.ekz.
Hi Derek,
This would require us to actually place the order, though, would it not?
I'm looking to estimate the cost of my spread, without placing the order at all. The goal is to calculate risk/reward, and determine whether to place the order or not.
Varad Kabade
Hi .ekz.,
To get the fees for a given order, we need to use the GetOrderFee method of the Security object, which takes the OrderFeeParameters object as input. Note that we need to use the MarketOrder object to get order parameter, which creates an Order object without placing the order. On the other hand, self.MarketOrder is a helper method that creates an OrderTicket object that tracks the order submitted to the brokerage.
Best,
Varad Kabade
.ekz.
Ah, interesting…
MarketOrder(…) creates an order object, vs self.MarketOrder(…) which sends one.
Is this the same case in C#?
ie: will MarketOrder(…) behave differently than this.MarketOrder(…)
Derek Melchin
Hi .ekz.,
To create a market order in C# without actually submitting the order, we can use
Note that we use `new MarketOrder` instead of just `MarketOrder` (or `this.MarketOrder`) which refers to the QCAlgorithm class method. See the attached backtest for reference.
Best,
Derek Melchin
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.
.ekz.
Aaah, yes of course.… I've been using python so much recently, I seem to have forgotten my roots. Ha.
Thanks for indulging such a trivial question.
.ekz.
I've just realized this won't work for Option strategies (like a BullPutSpread. Can you recommend an alternate approach? Do we calculate the fee for each leg separately? Or is the fee for the entire spread (ie one transaction)?
Derek Melchin
Hi .ekz.,
When using OptionStrategies, we recommend calculating the fees on each leg separately. This matches how the orders are actually executed (two transactions). See the attached backtest for reference.
Best,
Derek Melchin
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.
.ekz.
Roger that. Will do it this way then, thanks!
.ekz.
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!