Modifying orders
To modify an existing order, you create a new OrderProfileBase object based on the existing Order by calling the GetOrderProfile() method from the Order object. The new Order profile object contains the same property values as the existing Order. You can modify any properties of the Order profile object.
After making the desired changes, set the value of the OrderProfile.Action property to indicate how the existing order should be modified, as follows:
To delete the existing order, set the value to OrderAction.Delete.
To place the existing order on hold, set the value toOrderAction.Hold to resubmit a held order, set the value to OrderAction.Resubmit.
To modify the existing order values, set the value to OrderAction.Change.
Note
Some exchanges do not support a Change request for an Order. In these cases, the TT system accepts a Change request and converts it to a Cancel/Replace request before sending it to the exchange.
To cancel the existing Order and replace it with a new Order based on the new Order profile, set the value to OrderAction.Replace.
To update only the UserTag and UserData properties of the existing Order, set the value to OrderAction.Update.
Note
These properties are stored internally in the TT system and broadcast throughout the TT environment, but they are not sent to the Exchange.
The following code snippet demonstrates how to change the price of an order with a given key assuming that a TradeSubscription object named m_ts
has already been created.
void changeOrderPrice(string key, Price p)
{
if (m_ts.Orders.ContainsKey(key))
{
Order order = m_ts.Orders[key];
OrderProfile op = order.GetOrderProfile();
op.LimitPrice = p;
op.Action = OrderAction.Change;
if (!m_ts.SendOrder(op))
{
Console.WriteLine("Send change order Failed.");
}
else
{
Console.WriteLine("Sent order change request.”);
}
}
Using an existing order as a template for a new order
In addition to creating a new OrderProfile profile from an existing Order so you can modify the order, you can also create a new OrderProfile profile object to use as a template for a new order. The Order.CreateNewOrderProfile() method creates an Order profile object with the same properties as the Order object; however, you can use it only to submit a new Order.
Note
The Order.CreateNewOrderProfile() method does not modify the original Order; it only uses the details of the original Order as the basis for a new Order.