/* * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using QuantConnect.Interfaces; using QuantConnect.Securities; namespace QuantConnect.Orders { /// /// Combo limit order type /// /// Single limit price for the whole combo order public class ComboLimitOrder : ComboOrder { /// /// Combo Limit Order Type /// public override OrderType Type => OrderType.ComboLimit; /// /// Added a default constructor for JSON Deserialization: /// public ComboLimitOrder() : base() { } /// /// New limit order constructor /// /// Symbol asset we're seeking to trade /// Quantity of the asset we're seeking to trade /// Time the order was placed /// Manager for the orders in the group /// Price the order should be filled at if a limit order /// User defined data tag for this order /// The order properties for this order public ComboLimitOrder(Symbol symbol, decimal quantity, decimal limitPrice, DateTime time, GroupOrderManager groupOrderManager, string tag = "", IOrderProperties properties = null) : base(symbol, quantity, time, groupOrderManager, tag, properties) { GroupOrderManager.LimitPrice = limitPrice; } /// /// Gets the order value in units of the security's quote currency /// /// The security matching this order's symbol protected override decimal GetValueImpl(Security security) { return LimitOrder.CalculateOrderValue(Quantity, GroupOrderManager.LimitPrice, security.Price); } /// /// Modifies the state of this order to match the update request /// /// The request to update this order object public override void ApplyUpdateOrderRequest(UpdateOrderRequest request) { base.ApplyUpdateOrderRequest(request); if (request.LimitPrice.HasValue) { GroupOrderManager.LimitPrice = request.LimitPrice.Value; } } /// /// Creates a deep-copy clone of this order /// /// A copy of this order public override Order Clone() { var order = new ComboLimitOrder(); CopyTo(order); return order; } } }