Author |
Topic: How to get current PositionList()? (4 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
JGagnon Posts: 95 Joined: Apr 11, 2011 |
I am trying to iterate through the current list of positions to close out positions at end of market day. I am sure I am doing something simple that is wrong, the first line below that attempts to get the new PositionList() is returning an empty list.
private void button2_Click(object sender, EventArgs e) { var posList = new PositionList(); foreach (OEC.API.Position pos in posList) { NewOrderDraft draft = OECClient.Global.CreateDraft(); draft.Account = pos.Account; draft.Side = (pos.Net.Volume < 0) ? OrderSide.Buy : OrderSide.Sell; draft.Contract = pos.PositionContract; draft.Quantity = Math.Abs(pos.Net.Volume); draft.Type = OrderType.Market; if (draft.Quantity == 0) return;// nothing to close OECClient.Global.SendOrder(draft); } } John Gagnon |
||||
JGagnon Posts: 95 Joined: Apr 11, 2011 |
bump
John Gagnon |
||||
JGagnon Posts: 95 Joined: Apr 11, 2011 |
1 week bump, anyone there?
John Gagnon |
||||
VictorV Posts: 746 Joined: May 08, 2007 |
Actually, "new PositionList()" creates a new empty list. You need to use http://www.openecry.com/api/api/OEC.API.Account.AvgPositions.html to access the current positions
Victor Vins Lead Software Developer |
||||