public void CheckOrderStateAndCancelOrder(string execId, string side, string symbol) { var orderId = api.GetOrderNumber(execId); Thread.Sleep(1000); var state = api.GetOrderState(orderId); if (state.State != State.Cancelled && state.State != State.Filled) { FormHelper.FormSetText(String.Format("Did not get filled Cancel open orders")); if (side == "Buy") { api.CancelBuyOrdersForSymbol(symbol); } else if (side == "Sell") { api.CancelSellOrdersForSymbol(symbol); } Thread.Sleep(1000); } }