using System;
namespace Krs.Ats.IBNet
{
///
/// Order Status Event Arguments
///
[Serializable()]
public class OrderStatusEventArgs : EventArgs
{
private decimal averageFillPrice;
private int clientId;
private int filled;
private decimal lastFillPrice;
private int orderId;
private int parentId;
private int permId;
private int remaining;
private string whyHeld;
private OrderStatus status;
///
/// Full Constructor
///
/// The order Id that was specified previously in the call to placeOrder().
/// The order status.
/// Specifies the number of shares that have been executed.
/// Specifies the number of shares still outstanding.
/// The average price of the shares that have been executed.
/// This parameter is valid only if the filled parameter value
/// is greater than zero. Otherwise, the price parameter will be zero.
/// The TWS id used to identify orders. Remains the same over TWS sessions.
/// The order ID of the parent order, used for bracket and auto trailing stop orders.
/// The last price of the shares that have been executed. This parameter is valid
/// only if the filled parameter value is greater than zero. Otherwise, the price parameter will be zero.
/// The ID of the client (or TWS) that placed the order.
/// The TWS orders have a fixed clientId and orderId of 0 that distinguishes them from API orders.
/// This field is used to identify an order held when TWS is trying to locate shares for a short sell.
/// The value used to indicate this is 'locate'.
public OrderStatusEventArgs(int orderId, OrderStatus status, int filled, int remaining, decimal averageFillPrice,
int permId, int parentId, decimal lastFillPrice, int clientId, string whyHeld)
{
this.orderId = orderId;
this.clientId = clientId;
this.lastFillPrice = lastFillPrice;
this.parentId = parentId;
this.permId = permId;
this.averageFillPrice = averageFillPrice;
this.remaining = remaining;
this.filled = filled;
this.status = status;
this.whyHeld = whyHeld;
}
///
/// Parameterless OrderStatusEventArgs Constructor for serialization
///
public OrderStatusEventArgs()
{
this.orderId = -1;
this.clientId = -1;
this.lastFillPrice = -1;
this.parentId = -1;
this.permId = -1;
this.averageFillPrice = -1;
this.remaining = -1;
this.filled = -1;
this.status = OrderStatus.Error; //OrderStatus.None;
this.whyHeld = "";
}
///
/// The order Id that was specified previously in the call to placeOrder().
///
public int OrderId
{
get { return orderId; }
set { orderId = value; }
}
///
/// The order status.
///
/// Possible values include:
///
///
/// Status
/// Description
///
/// -
/// PendingSubmit
/// indicates that you have transmitted the order, but have not yet received confirmation that it has been accepted by the order destination. This order status is not sent by TWS and should be explicitly set by the API developer when an order is submitted.
///
/// -
/// PendingCancel
/// Indicates that you have sent a request to cancel the order but have not yet received cancel confirmation from the order destination. At this point, your order is not confirmed canceled. You may still receive an execution while your cancellation request is pending. This order status is not sent by TWS and should be explicitly set by the API developer when an order is canceled.
///
/// -
/// PreSubmitted
/// Indicates that a simulated order type has been accepted by the IB system and that this order has yet to be elected. The order is held in the IB system (and the status remains DARK BLUE) until the election criteria are met. At that time the order is transmitted to the order destination as specified (and the order status color will change).
///
/// -
/// Submitted
/// Indicates that your order has been accepted at the order destination and is working.
///
/// -
/// Cancelled
/// Indicates that the balance of your order has been confirmed canceled by the IB system. This could occur unexpectedly when IB or the destination has rejected your order.
///
/// -
/// Filled
/// The order has been completely filled.
///
///
///
///
public OrderStatus Status
{
get { return status; }
set { status = value; }
}
///
/// Specifies the number of shares that have been executed.
///
public int Filled
{
get { return filled; }
set { filled = value; }
}
///
/// Specifies the number of shares still outstanding.
///
public int Remaining
{
get { return remaining; }
set { remaining = value; }
}
///
/// The average price of the shares that have been executed.
/// This parameter is valid only if the filled parameter value
/// is greater than zero. Otherwise, the price parameter will be zero.
///
public decimal AverageFillPrice
{
get { return averageFillPrice; }
set { averageFillPrice = value; }
}
///
/// The TWS id used to identify orders. Remains the same over TWS sessions.
///
public int PermId
{
get { return permId; }
set { permId = value; }
}
///
/// The order ID of the parent order, used for bracket and auto trailing stop orders.
///
public int ParentId
{
get { return parentId; }
set { parentId = value; }
}
///
/// The last price of the shares that have been executed. This parameter is valid
/// only if the filled parameter value is greater than zero. Otherwise, the price parameter will be zero.
///
public decimal LastFillPrice
{
get { return lastFillPrice; }
set { lastFillPrice = value; }
}
///
/// The ID of the client (or TWS) that placed the order.
/// The TWS orders have a fixed clientId and orderId of 0 that distinguishes them from API orders.
///
public int ClientId
{
get { return clientId; }
set { clientId = value; }
}
///
/// This field is used to identify an order held when TWS is trying to locate shares for a short sell.
/// The value used to indicate this is 'locate'.
///
/// This field is supported starting with TWS release 872.
public string WhyHeld
{
get { return whyHeld; }
set { whyHeld = value; }
}
}
}