public async Task ModifyMarketOrder(string accountId, OAOrder order) { SetCredentials(accountId); PriceInformation priceInformation = new PriceInformation(); priceInformation.instrument = await GetInstrument(accountId, order.Instrument); priceInformation.priceProperties = new List <string>(); PatchExitOrdersRequest request = new PatchExitOrdersRequest(); request.stopLoss = new StopLossDetails(instruments[0]); request.stopLoss.price = Math.Round(order.SL, priceInformation.instrument.displayPrecision); request.stopLoss.timeInForce = TimeInForce.GoodUntilCancelled; if (order.PT > 1) // != 0, kvuli zaokrouhlovani { request.takeProfit = new TakeProfitDetails(instruments[0]); request.takeProfit.price = Math.Round(order.PT, priceInformation.instrument.displayPrecision); request.takeProfit.timeInForce = TimeInForce.GoodUntilCancelled; } else { request.takeProfit = null; } try { TradePatchExitOrdersResponse tradePatchExitOrdersResponse = await Rest20.PatchTradeExitOrders(accountId, order.Id, request); } catch (Exception e) { if (e.Message.IndexOf("NO_SUCH_TRADE") > 0) { return; } throw e; } }