/*
* 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 System.Collections.Generic;
namespace QuantConnect.Orders
{
///
/// Defines a request to update an order's values
///
public class UpdateOrderRequest : OrderRequest
{
///
/// Gets
///
public override OrderRequestType OrderRequestType
{
get { return OrderRequestType.Update; }
}
///
/// Gets the new quantity of the order, null to not change the quantity
///
public decimal? Quantity { get; private set; }
///
/// Gets the new limit price of the order, null to not change the limit price
///
public decimal? LimitPrice { get; private set; }
///
/// Gets the new stop price of the order, null to not change the stop price
///
public decimal? StopPrice { get; private set; }
///
/// Initializes a new instance of the class
///
/// The time the request was submitted
/// The order id to be updated
/// The fields defining what should be updated
public UpdateOrderRequest(DateTime time, int orderId, UpdateOrderFields fields)
: base(time, orderId, fields.Tag)
{
Quantity = fields.Quantity;
LimitPrice = fields.LimitPrice;
StopPrice = fields.StopPrice;
}
///
/// Returns a string that represents the current object.
///
///
/// A string that represents the current object.
///
/// 2
public override string ToString()
{
var updates = new List();
if (Quantity.HasValue)
{
updates.Add("Quantity: " + Quantity.Value);
}
if (LimitPrice.HasValue)
{
updates.Add("LimitPrice: " + LimitPrice.Value.SmartRounding());
}
if (StopPrice.HasValue)
{
updates.Add("StopPrice: " + StopPrice.Value.SmartRounding());
}
return string.Format("{0} UTC: Update Order: ({1}) - {2} {3} Status: {4}", Time, OrderId, string.Join(", ", updates), Tag, Status);
}
}
}