i need to test whether HasSufficientBuyingPowerForOrderResult before order multi leg option order
i found source code
/// <summary>
/// Check if there is sufficient buying power for the position group to execute this order.
/// </summary>
public static HasSufficientBuyingPowerForOrderResult HasSufficientBuyingPowerForOrder(
this IPositionGroupBuyingPowerModel model,
SecurityPortfolioManager portfolio,
IPositionGroup positionGroup,
Order order
)
{
return model.HasSufficientBuyingPowerForOrder(new HasSufficientPositionGroupBuyingPowerForOrderParameters(
portfolio, positionGroup, order
));
}
place OptionStrategy use below method
/// <summary>
/// Issue an order/trade for buying/selling an option strategy
/// </summary>
/// <param name="strategy">Specification of the strategy to trade</param>
/// <param name="quantity">Quantity of the strategy to trade</param>
/// <param name="orderProperties">The order properties to use. Defaults to <see cref="DefaultOrderProperties"/></param>
/// <returns>Sequence of order tickets</returns>
public IEnumerable<OrderTicket> Order(OptionStrategy strategy, int quantity, IOrderProperties orderProperties = null)
{
return GenerateOrders(strategy, quantity, orderProperties);
}
i just wonder `Order` params in `HasSufficientBuyingPowerForOrderResult` how to build
Fred Painchaud
Hello Nemo,
The HasSufficientBuyingPowerForOrder method is defined in BuyingPowerModel. You need to define your own BuyingPowerModel from deriving from the class and then set it to the security with SetBuyingPowerModel. The following should help a bit:
So, your overridden HasSufficientBuyingPowerForOrder method will receiving the param Order from the Algo. Basically, with all the params passed to the method, you can determine if the portfolio has enough buying power to fulfill the order, implementing your own “buying power determination”.
Fred
Cool nemo
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!