/* * 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; namespace QuantConnect.Orders { /// /// Defines a request to submit a new order /// public class SubmitOrderRequest : OrderRequest { /// /// Gets /// public override OrderRequestType OrderRequestType { get { return OrderRequestType.Submit; } } /// /// Gets the security type of the symbol /// public SecurityType SecurityType { get; private set; } /// /// Gets the symbol to be traded /// public Symbol Symbol { get; private set; } /// /// Gets the order type od the order /// public OrderType OrderType { get; private set; } /// /// Gets the quantity of the order /// public decimal Quantity { get; private set; } /// /// Gets the limit price of the order, zero if not a limit order /// public decimal LimitPrice { get; private set; } /// /// Gets the stop price of the order, zero if not a stop order /// public decimal StopPrice { get; private set; } /// /// Price which must first be reached before a limit order can be submitted. /// public decimal TriggerPrice { get; private set; } /// /// Trailing amount for a trailing stop order /// public decimal TrailingAmount { get; private set; } /// /// Determines whether the is a percentage or an absolute currency value /// public bool TrailingAsPercentage { get; private set; } /// /// Gets the order properties for this request /// public IOrderProperties OrderProperties { get; private set; } /// /// Gets the manager for the combo order. If null, the order is not a combo order. /// public GroupOrderManager GroupOrderManager { get; private set; } /// /// Initializes a new instance of the class. /// The will default to /// /// The order type to be submitted /// The symbol's /// The symbol to be traded /// The number of units to be ordered /// The stop price for stop orders, non-stop orders this value is ignored /// The limit price for limit orders, non-limit orders this value is ignored /// The trigger price for limit if touched orders, for non-limit if touched orders this value is ignored /// The trailing amount to be used to update the stop price /// Whether the is a percentage or an absolute currency value /// The time this request was created /// A custom tag for this request /// The order properties for this request /// The manager for this combo order public SubmitOrderRequest( OrderType orderType, SecurityType securityType, Symbol symbol, decimal quantity, decimal stopPrice, decimal limitPrice, decimal triggerPrice, decimal trailingAmount, bool trailingAsPercentage, DateTime time, string tag, IOrderProperties properties = null, GroupOrderManager groupOrderManager = null ) : base(time, (int)OrderResponseErrorCode.UnableToFindOrder, tag) { SecurityType = securityType; Symbol = symbol; GroupOrderManager = groupOrderManager; OrderType = orderType; Quantity = quantity; LimitPrice = limitPrice; StopPrice = stopPrice; TriggerPrice = triggerPrice; TrailingAmount = trailingAmount; TrailingAsPercentage = trailingAsPercentage; OrderProperties = properties; } /// /// Initializes a new instance of the class. /// The will default to /// /// The order type to be submitted /// The symbol's /// The symbol to be traded /// The number of units to be ordered /// The stop price for stop orders, non-stop orders this value is ignored /// The limit price for limit orders, non-limit orders this value is ignored /// The trigger price for limit if touched orders, for non-limit if touched orders this value is ignored /// The time this request was created /// A custom tag for this request /// The order properties for this request /// The manager for this combo order public SubmitOrderRequest( OrderType orderType, SecurityType securityType, Symbol symbol, decimal quantity, decimal stopPrice, decimal limitPrice, decimal triggerPrice, DateTime time, string tag, IOrderProperties properties = null, GroupOrderManager groupOrderManager = null ) : this(orderType, securityType, symbol, quantity, stopPrice, limitPrice, triggerPrice, 0, false, time, tag, properties, groupOrderManager) { } /// /// Initializes a new instance of the class. /// The will default to /// /// The order type to be submitted /// The symbol's /// The symbol to be traded /// The number of units to be ordered /// The stop price for stop orders, non-stop orders this value is ignored /// The limit price for limit orders, non-limit orders this value is ignored /// The time this request was created /// A custom tag for this request /// The order properties for this request /// The manager for this combo order public SubmitOrderRequest( OrderType orderType, SecurityType securityType, Symbol symbol, decimal quantity, decimal stopPrice, decimal limitPrice, DateTime time, string tag, IOrderProperties properties = null, GroupOrderManager groupOrderManager = null ) : this(orderType, securityType, symbol, quantity, stopPrice, limitPrice, 0, time, tag, properties, groupOrderManager) { } /// /// Sets the /// /// The order id of the generated order internal void SetOrderId(int orderId) { OrderId = orderId; } /// /// Returns a string that represents the current object. /// /// /// A string that represents the current object. /// /// 2 public override string ToString() { return Messages.SubmitOrderRequest.ToString(this); } } }