コード例 #1
0
ファイル: OrdersController.cs プロジェクト: alpo-8/MT
        public Task ChangeAsync(string orderId, [FromBody] OrderChangeRequest request)
        {
            if (!_ordersCache.TryGetOrderById(orderId, out var order))
            {
                throw new InvalidOperationException("Order not found");
            }

            try
            {
                var originator = GetOriginator(request.Originator);

                var correlationId = string.IsNullOrWhiteSpace(request.CorrelationId)
                    ? _identityGenerator.GenerateGuid()
                    : request.CorrelationId;

                _tradingEngine.ChangeOrder(order.Id, request.Price, request.Validity, originator,
                                           request.AdditionalInfo, correlationId, request.ForceOpen);
            }
            catch (ValidateOrderException ex)
            {
                throw new InvalidOperationException(ex.Message);
            }

            _operationsLogService.AddLog("action order.changeLimits", order.AccountId,
                                         new { orderId = orderId, request = request.ToJson() }.ToJson(), "");

            return(Task.CompletedTask);
        }