Lean
$LEAN_TAG$
CrossZeroSecondOrderRequest.cs
1
/*
2
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
16
using
QuantConnect
.
Orders
;
17
18
namespace
QuantConnect.Brokerages.CrossZero
19
{
20
/// <summary>
21
/// Represents a second request to cross zero order.
22
/// </summary>
23
public
class
CrossZeroSecondOrderRequest
:
CrossZeroFirstOrderRequest
24
{
25
/// <summary>
26
/// Gets or sets the first part of CrossZeroOrder.
27
/// </summary>
28
public
CrossZeroFirstOrderRequest
FirstPartCrossZeroOrder
{
get
; }
29
30
/// <summary>
31
/// Initializes a new instance of the <see cref="CrossZeroFirstOrderRequest"/> struct.
32
/// </summary>
33
/// <param name="leanOrder">The lean order.</param>
34
/// <param name="orderType">The type of the order.</param>
35
/// <param name="orderQuantity">The quantity of the order.</param>
36
/// <param name="orderQuantityHolding">The current holding quantity of the order's symbol.</param>
37
/// <param name="orderPosition">The position of the order, which depends on the <paramref name="orderQuantityHolding"/>.</param>
38
/// <param name="crossZeroFirstOrder">The first part of the cross zero order.</param>
39
public
CrossZeroSecondOrderRequest
(
Order
leanOrder,
OrderType
orderType, decimal orderQuantity, decimal orderQuantityHolding,
40
OrderPosition
orderPosition,
CrossZeroFirstOrderRequest
crossZeroFirstOrder)
41
: base(leanOrder, ConvertStopCrossingOrderType(orderType), orderQuantity, orderQuantityHolding, orderPosition)
42
{
43
FirstPartCrossZeroOrder
= crossZeroFirstOrder;
44
}
45
46
/// <summary>
47
/// Converts a stop order type to its corresponding market or limit order type.
48
/// </summary>
49
/// <param name="orderType">The original order type to be converted.</param>
50
/// <returns>
51
/// The converted order type. If the original order type is <see cref="OrderType.StopMarket"/>,
52
/// it returns <see cref="OrderType.Market"/>. If the original order type is <see cref="OrderType.StopLimit"/>,
53
/// it returns <see cref="OrderType.Limit"/>. Otherwise, it returns the original order type.
54
/// </returns>
55
private
static
OrderType
ConvertStopCrossingOrderType(
OrderType
orderType) => orderType
switch
56
{
57
OrderType
.StopMarket =>
OrderType
.Market,
58
OrderType
.StopLimit =>
OrderType
.Limit,
59
_ => orderType
60
};
61
}
62
}
Brokerages
CrossZero
CrossZeroSecondOrderRequest.cs
Generated by
1.8.17