public void deleteOCOs(IFXManager fxManager) { string tn = "ORDERS"; orderMap = fxManager.getTable(tn); //fxManager.printMap(tn, orderMap); // delete where type = SE foreach (Dictionary<string, string> map in orderMap.Values) { string type = map["Type"]; string oid = map["OrderID"]; string coid = map["ContingentOrderID"]; if (type == "SE" && oid != "" //&& coid != "" // the orphaned LSEs don't have a contingency id but need to be deleted, too ) { deleteOrder(oid); } } }
public void closePositions(IFXManager fxManager) { string tn = "TRADES"; positionMap = fxManager.getTable(tn); //fxManager.printMap(tn, orderMap); foreach (Dictionary<string, string> map in positionMap.Values) { string tradeId = map["TradeID"]; string offerId = map["OfferID"]; string accountId = map["AccountID"]; string sAmount = map["Amount"]; int amount = int.Parse(sAmount); string buySell = map["BuySell"]; string sBuySell = ""; if (buySell.Equals("B")) // switch "BuySell" sBuySell = "S"; // (if the position in "Buy", close position will be "Sell" and vice versa) else sBuySell = "B"; closePosition(tradeId, offerId, accountId, -1, sBuySell, null); } }