API Support Forum
OEC API > API Support > Client id for an order
Author Topic: Client id for an order
(4 messages, Page 1 of 1)
Moderators: VPfau
MSukhov28
Posts: 4
Joined: Jul 23, 2013


Posted: Nov 15, 2016 @ 09:19 AM             Msg. 1 of 4
Is the any option to set own identifier for placing orders?
CMicciche902
Posts: 367
Joined:


Posted: Nov 15, 2016 @ 03:10 PM             Msg. 2 of 4
Can you advise what you mean? Do you mean be able to send a comment?
According to https://gainfutures.com/api/html/9900566b-260a-4247-8326-9698b013e7b8.htm

static void oecapi_OnPriceTick(OEC.API.Contract contract, OEC.API.Price price)
{
if (Math.Abs(price.LastPrice - price.BidPrice) < contract.TickSize)
PlaceOrder(contract, OEC.Data.OrderSide.Buy, price.BidPrice, "By Bid");
else if (Math.Abs(price.LastPrice - price.AskPrice) < contract.TickSize)
PlaceOrder(contract, OEC.Data.OrderSide.Sell, price.AskPrice, "By Ask");
}

private static void PlaceOrder(OEC.API.Contract contract, OEC.Data.OrderSide orderSide, double limitPrice, string comments)
{
if (oecapi.Orders.Count == 0 || oecapi.Orders.Last.IsFinalState)
{
OEC.API.NewOrderDraft orderDraft = oecapi.CreateDraft();
orderDraft.Account = oecapi.Accounts.First;
orderDraft.Contract = contract;
orderDraft.Side = orderSide;
orderDraft.Type = OEC.Data.OrderType.Limit;
orderDraft.Price = limitPrice;
orderDraft.Quantity = 1;
orderDraft.End = DateTime.UtcNow.AddMinutes(1);
orderDraft.Comments = comments;
OEC.API.OrderParts invalidOrderParts = orderDraft.GetInvalidParts();
if (invalidOrderParts != OEC.API.OrderParts.None)
{
Console.WriteLine("ERROR. Order {0} {1} {2} @ {3} Limit is invalid: {4}", orderSide, orderDraft.Quantity, contract.Symbol, contract.PriceToString(limitPrice), invalidOrderParts);
}
else
{
OEC.API.Order order = oecapi.SendOrder(orderDraft);
Console.WriteLine("Order {0} was sent", order);
}
}
}


Comments topic:
https://gainfutures.com/api/html/P_OEC_API_OrderDraft_Comments.htm
Chris M
MSukhov28
Posts: 4
Joined: Jul 23, 2013


Posted: Nov 15, 2016 @ 04:46 PM             Msg. 3 of 4
Do you have some numeric fields for ID?

Order.ID set by internal OEC logic. We need to pass unique user id to each order. That should be stored on server side and ability to get it while restart the trading app.
CMicciche902
Posts: 367
Joined:


Posted: Nov 15, 2016 @ 05:03 PM             Msg. 4 of 4
Some third parties have used comments field for such purpose.
Chris M