API Support Forum
OEC API > Order Execution > switch from short to long in one operation
Author Topic: switch from short to long in one operation
(5 messages, Page 1 of 1)
Moderators: VPfau
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Oct 16, 2009 @ 02:49 PM             Msg. 1 of 5
Hello,
I'm interested in implementing a switch from short to long (and vice versa) in one operation. is it doable using the API?
currently, i'm using the following code to send an order. Is it correct, or am I missing some steps?

//////////////////////////////////////////////////////////

d.Side = OEC.Data.OrderSide.Buy;
d.Quantity = 1;// (int)nQty.Value;
d.Contract = oecClient1.Contracts["ESZ9"];
d.Type = OEC.Data.OrderType.Market;
OEC.API.OrderParts res = d.GetInvalidParts();
if (res != OEC.API.OrderParts.None)
throw new Exception(string.Format("Invalid values in {0}", res));

OEC.API.Order order = oecClient1.SendOrder(d);
//////////////////////////////////////////////////////////


Best regards,
YBar
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Oct 16, 2009 @ 04:37 PM             Msg. 2 of 5
Yes, you can reverse your position using one order.
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Oct 16, 2009 @ 04:53 PM             Msg. 3 of 5
Thanks SergeK, could you please send an example of how to do so?

YBar
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Oct 16, 2009 @ 05:00 PM             Msg. 4 of 5
you need to set the order quantity to 2 to reverse from short 1 to long 1.
YBar
Posts: 24
Joined: Dec 01, 2008


Posted: Oct 16, 2009 @ 05:13 PM             Msg. 5 of 5
of course... thanks a lot for your quick help.