/*
* 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 QuantConnect.Orders;
namespace QuantConnect.Brokerages.CrossZero
{
///
/// Represents a second request to cross zero order.
///
public class CrossZeroSecondOrderRequest : CrossZeroFirstOrderRequest
{
///
/// Gets or sets the first part of CrossZeroOrder.
///
public CrossZeroFirstOrderRequest FirstPartCrossZeroOrder { get; }
///
/// Initializes a new instance of the struct.
///
/// The lean order.
/// The type of the order.
/// The quantity of the order.
/// The current holding quantity of the order's symbol.
/// The position of the order, which depends on the .
/// The first part of the cross zero order.
public CrossZeroSecondOrderRequest(Order leanOrder, OrderType orderType, decimal orderQuantity, decimal orderQuantityHolding,
OrderPosition orderPosition, CrossZeroFirstOrderRequest crossZeroFirstOrder)
: base(leanOrder, ConvertStopCrossingOrderType(orderType), orderQuantity, orderQuantityHolding, orderPosition)
{
FirstPartCrossZeroOrder = crossZeroFirstOrder;
}
///
/// Converts a stop order type to its corresponding market or limit order type.
///
/// The original order type to be converted.
///
/// The converted order type. If the original order type is ,
/// it returns . If the original order type is ,
/// it returns . Otherwise, it returns the original order type.
///
private static OrderType ConvertStopCrossingOrderType(OrderType orderType) => orderType switch
{
OrderType.StopMarket => OrderType.Market,
OrderType.StopLimit => OrderType.Limit,
_ => orderType
};
}
}