Exemplo n.º 1
0
        public async Task <ResponseModel <LimitOrderResponseModel> > PlaceStopLimitOrderAsync(
            string clientId, AssetPair assetPair, OrderAction orderAction, decimal volume,
            decimal?lowerPrice, decimal?lowerLimitPrice, decimal?upperPrice, decimal?upperLimitPrice, bool cancelPreviousOrders = false)
        {
            var requestId = GetNextRequestId();

            var fees = _calculateOrderFees
                ? await _feeCalculator.GetLimitOrderFees(clientId, assetPair, orderAction)
                : Array.Empty <LimitOrderFeeModel>();

            var order = new StopLimitOrderModel
            {
                Id                   = requestId.ToString(),
                AssetPairId          = assetPair.Id,
                ClientId             = clientId,
                LowerPrice           = (double?)lowerPrice,
                LowerLimitPrice      = (double?)lowerLimitPrice,
                UpperPrice           = (double?)upperPrice,
                UpperLimitPrice      = (double?)upperLimitPrice,
                CancelPreviousOrders = cancelPreviousOrders,
                Volume               = (double)Math.Abs(volume),
                OrderAction          = orderAction.ToMeOrderAction(),
                Fees                 = fees
            };

            var response = await _matchingEngineClient.PlaceStopLimitOrderAsync(order);

            CheckResponseAndThrowIfNull(response);

            var result = new LimitOrderResponseModel
            {
                Id = requestId
            };

            return(ConvertToApiModel(response.Status, result));
        }