Ejemplo n.º 1
0
        public MtBackendResponse <bool> ChangeOrderLimits([FromBody] ChangeOrderLimitsBackendRequest request)
        {
            var order = _ordersCache.GetOrderById(request.OrderId);

            if (_assetDayOffService.IsDayOff(order.Instrument))
            {
                return(new MtBackendResponse <bool> {
                    Message = "Trades for instrument are not available"
                });
            }

            try
            {
                _tradingEngine.ChangeOrderLimits(request.OrderId, request.StopLoss, request.TakeProfit,
                                                 request.ExpectedOpenPrice);
            }
            catch (ValidateOrderException ex)
            {
                return(new MtBackendResponse <bool> {
                    Result = false, Message = ex.Message
                });
            }

            var result = new MtBackendResponse <bool> {
                Result = true
            };

            _consoleWriter.WriteLine($"action order.changeLimits for clientId = {request.ClientId}, orderId = {request.OrderId}");
            _operationsLogService.AddLog("action order.changeLimits", request.ClientId, order.AccountId, request.ToJson(), result.ToJson());

            return(result);
        }