Lean
$LEAN_TAG$
UpdateOrderRequest.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
System;
17
18
namespace
QuantConnect.Orders
19
{
20
/// <summary>
21
/// Defines a request to update an order's values
22
/// </summary>
23
public
class
UpdateOrderRequest
:
OrderRequest
24
{
25
/// <summary>
26
/// Gets <see cref="Orders.OrderRequestType.Update"/>
27
/// </summary>
28
public
override
OrderRequestType
OrderRequestType
29
{
30
get
{
return
OrderRequestType
.Update; }
31
}
32
33
/// <summary>
34
/// Gets the new quantity of the order, null to not change the quantity
35
/// </summary>
36
public
decimal?
Quantity
{
get
;
private
set
; }
37
38
/// <summary>
39
/// Gets the new limit price of the order, null to not change the limit price
40
/// </summary>
41
public
decimal?
LimitPrice
{
get
;
private
set
; }
42
43
/// <summary>
44
/// Gets the new stop price of the order, null to not change the stop price
45
/// </summary>
46
public
decimal?
StopPrice
{
get
;
private
set
; }
47
48
/// <summary>
49
/// Gets the new trigger price of the order, null to not change the trigger price
50
/// </summary>
51
public
decimal?
TriggerPrice
{
get
;
private
set
; }
52
53
/// <summary>
54
/// The trailing stop order trailing amount
55
/// </summary>
56
public
decimal?
TrailingAmount
{
get
;
private
set
; }
57
58
/// <summary>
59
/// Initializes a new instance of the <see cref="UpdateOrderRequest"/> class
60
/// </summary>
61
/// <param name="time">The time the request was submitted</param>
62
/// <param name="orderId">The order id to be updated</param>
63
/// <param name="fields">The fields defining what should be updated</param>
64
public
UpdateOrderRequest
(DateTime time,
int
orderId,
UpdateOrderFields
fields)
65
: base(time, orderId, fields.
Tag
)
66
{
67
Quantity
= fields.
Quantity
;
68
LimitPrice
= fields.
LimitPrice
;
69
StopPrice
= fields.
StopPrice
;
70
TriggerPrice
= fields.
TriggerPrice
;
71
TrailingAmount
= fields.
TrailingAmount
;
72
}
73
74
/// <summary>
75
/// Returns a string that represents the current object.
76
/// </summary>
77
/// <returns>
78
/// A string that represents the current object.
79
/// </returns>
80
/// <filterpriority>2</filterpriority>
81
public
override
string
ToString
()
82
{
83
return
Messages
.
UpdateOrderRequest
.
ToString
(
this
);
84
}
85
86
/// <summary>
87
/// Checks whether the update request is allowed for a closed order.
88
/// Only tag updates are allowed on closed orders.
89
/// </summary>
90
/// <returns>True if the update request is allowed for a closed order</returns>
91
public
bool
IsAllowedForClosedOrder
()
92
{
93
return
!
Quantity
.HasValue && !
LimitPrice
.HasValue && !
StopPrice
.HasValue && !
TriggerPrice
.HasValue & !
TrailingAmount
.HasValue;
94
}
95
}
96
}
Common
Orders
UpdateOrderRequest.cs
Generated by
1.8.17