Lean  $LEAN_TAG$
SubmitOrderRequest.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;
18 
19 namespace QuantConnect.Orders
20 {
21  /// <summary>
22  /// Defines a request to submit a new order
23  /// </summary>
25  {
26  /// <summary>
27  /// Gets <see cref="Orders.OrderRequestType.Submit"/>
28  /// </summary>
29  public override OrderRequestType OrderRequestType
30  {
31  get { return OrderRequestType.Submit; }
32  }
33 
34  /// <summary>
35  /// Gets the security type of the symbol
36  /// </summary>
38  {
39  get; private set;
40  }
41 
42  /// <summary>
43  /// Gets the symbol to be traded
44  /// </summary>
45  public Symbol Symbol
46  {
47  get; private set;
48  }
49 
50  /// <summary>
51  /// Gets the order type od the order
52  /// </summary>
53  public OrderType OrderType
54  {
55  get; private set;
56  }
57 
58  /// <summary>
59  /// Gets the quantity of the order
60  /// </summary>
61  public decimal Quantity
62  {
63  get; private set;
64  }
65 
66  /// <summary>
67  /// Gets the limit price of the order, zero if not a limit order
68  /// </summary>
69  public decimal LimitPrice
70  {
71  get; private set;
72  }
73 
74  /// <summary>
75  /// Gets the stop price of the order, zero if not a stop order
76  /// </summary>
77  public decimal StopPrice
78  {
79  get; private set;
80  }
81 
82  /// <summary>
83  /// Price which must first be reached before a limit order can be submitted.
84  /// </summary>
85  public decimal TriggerPrice
86  {
87  get; private set;
88  }
89 
90  /// <summary>
91  /// Trailing amount for a trailing stop order
92  /// </summary>
93  public decimal TrailingAmount
94  {
95  get; private set;
96  }
97 
98  /// <summary>
99  /// Determines whether the <see cref="TrailingAmount"/> is a percentage or an absolute currency value
100  /// </summary>
101  public bool TrailingAsPercentage
102  {
103  get; private set;
104  }
105 
106  /// <summary>
107  /// Gets the order properties for this request
108  /// </summary>
110  {
111  get; private set;
112  }
113 
114  /// <summary>
115  /// Gets the manager for the combo order. If null, the order is not a combo order.
116  /// </summary>
118  {
119  get; private set;
120  }
121 
122  /// <summary>
123  /// Initializes a new instance of the <see cref="SubmitOrderRequest"/> class.
124  /// The <see cref="OrderRequest.OrderId"/> will default to <see cref="OrderResponseErrorCode.UnableToFindOrder"/>
125  /// </summary>
126  /// <param name="orderType">The order type to be submitted</param>
127  /// <param name="securityType">The symbol's <see cref="SecurityType"/></param>
128  /// <param name="symbol">The symbol to be traded</param>
129  /// <param name="quantity">The number of units to be ordered</param>
130  /// <param name="stopPrice">The stop price for stop orders, non-stop orders this value is ignored</param>
131  /// <param name="limitPrice">The limit price for limit orders, non-limit orders this value is ignored</param>
132  /// <param name="triggerPrice">The trigger price for limit if touched orders, for non-limit if touched orders this value is ignored</param>
133  /// <param name="trailingAmount">The trailing amount to be used to update the stop price</param>
134  /// <param name="trailingAsPercentage">Whether the <paramref name="trailingAmount"/> is a percentage or an absolute currency value</param>
135  /// <param name="time">The time this request was created</param>
136  /// <param name="tag">A custom tag for this request</param>
137  /// <param name="properties">The order properties for this request</param>
138  /// <param name="groupOrderManager">The manager for this combo order</param>
140  OrderType orderType,
141  SecurityType securityType,
142  Symbol symbol,
143  decimal quantity,
144  decimal stopPrice,
145  decimal limitPrice,
146  decimal triggerPrice,
147  decimal trailingAmount,
148  bool trailingAsPercentage,
149  DateTime time,
150  string tag,
151  IOrderProperties properties = null,
152  GroupOrderManager groupOrderManager = null
153  )
154  : base(time, (int)OrderResponseErrorCode.UnableToFindOrder, tag)
155  {
156  SecurityType = securityType;
157  Symbol = symbol;
158  GroupOrderManager = groupOrderManager;
159  OrderType = orderType;
160  Quantity = quantity;
161  LimitPrice = limitPrice;
162  StopPrice = stopPrice;
163  TriggerPrice = triggerPrice;
164  TrailingAmount = trailingAmount;
165  TrailingAsPercentage = trailingAsPercentage;
166  OrderProperties = properties;
167  }
168 
169  /// <summary>
170  /// Initializes a new instance of the <see cref="SubmitOrderRequest"/> class.
171  /// The <see cref="OrderRequest.OrderId"/> will default to <see cref="OrderResponseErrorCode.UnableToFindOrder"/>
172  /// </summary>
173  /// <param name="orderType">The order type to be submitted</param>
174  /// <param name="securityType">The symbol's <see cref="SecurityType"/></param>
175  /// <param name="symbol">The symbol to be traded</param>
176  /// <param name="quantity">The number of units to be ordered</param>
177  /// <param name="stopPrice">The stop price for stop orders, non-stop orders this value is ignored</param>
178  /// <param name="limitPrice">The limit price for limit orders, non-limit orders this value is ignored</param>
179  /// <param name="triggerPrice">The trigger price for limit if touched orders, for non-limit if touched orders this value is ignored</param>
180  /// <param name="time">The time this request was created</param>
181  /// <param name="tag">A custom tag for this request</param>
182  /// <param name="properties">The order properties for this request</param>
183  /// <param name="groupOrderManager">The manager for this combo order</param>
185  OrderType orderType,
186  SecurityType securityType,
187  Symbol symbol,
188  decimal quantity,
189  decimal stopPrice,
190  decimal limitPrice,
191  decimal triggerPrice,
192  DateTime time,
193  string tag,
194  IOrderProperties properties = null,
195  GroupOrderManager groupOrderManager = null
196  )
197  : this(orderType, securityType, symbol, quantity, stopPrice, limitPrice, triggerPrice, 0, false, time, tag, properties,
198  groupOrderManager)
199  {
200  }
201 
202  /// <summary>
203  /// Initializes a new instance of the <see cref="SubmitOrderRequest"/> class.
204  /// The <see cref="OrderRequest.OrderId"/> will default to <see cref="OrderResponseErrorCode.UnableToFindOrder"/>
205  /// </summary>
206  /// <param name="orderType">The order type to be submitted</param>
207  /// <param name="securityType">The symbol's <see cref="SecurityType"/></param>
208  /// <param name="symbol">The symbol to be traded</param>
209  /// <param name="quantity">The number of units to be ordered</param>
210  /// <param name="stopPrice">The stop price for stop orders, non-stop orders this value is ignored</param>
211  /// <param name="limitPrice">The limit price for limit orders, non-limit orders this value is ignored</param>
212  /// <param name="time">The time this request was created</param>
213  /// <param name="tag">A custom tag for this request</param>
214  /// <param name="properties">The order properties for this request</param>
215  /// <param name="groupOrderManager">The manager for this combo order</param>
217  OrderType orderType,
218  SecurityType securityType,
219  Symbol symbol,
220  decimal quantity,
221  decimal stopPrice,
222  decimal limitPrice,
223  DateTime time,
224  string tag,
225  IOrderProperties properties = null,
226  GroupOrderManager groupOrderManager = null
227  )
228  : this(orderType, securityType, symbol, quantity, stopPrice, limitPrice, 0, time, tag, properties, groupOrderManager)
229  {
230  }
231 
232  /// <summary>
233  /// Sets the <see cref="OrderRequest.OrderId"/>
234  /// </summary>
235  /// <param name="orderId">The order id of the generated order</param>
236  internal void SetOrderId(int orderId)
237  {
238  OrderId = orderId;
239  }
240 
241  /// <summary>
242  /// Returns a string that represents the current object.
243  /// </summary>
244  /// <returns>
245  /// A string that represents the current object.
246  /// </returns>
247  /// <filterpriority>2</filterpriority>
248  public override string ToString()
249  {
250  return Messages.SubmitOrderRequest.ToString(this);
251  }
252  }
253 }