コード例 #1
0
 public static (HftApiErrorCode code, string message) ToHftApiError(this MeStatusCodes meCode)
 {
     return(meCode switch
     {
         MeStatusCodes.Ok => (HftApiErrorCode.Success, string.Empty),
         MeStatusCodes.BadRequest => (HftApiErrorCode.MeBadRequest, "Bad request"),
         MeStatusCodes.LowBalance => (HftApiErrorCode.MeLowBalance, "Low balance"),
         MeStatusCodes.AlreadyProcessed => (HftApiErrorCode.MeAlreadyProcessed, "Already processed"),
         MeStatusCodes.DisabledAsset => (HftApiErrorCode.MeDisabledAsset, "Asset is disabled"),
         MeStatusCodes.UnknownAsset => (HftApiErrorCode.MeUnknownAsset, "Unknown asset"),
         MeStatusCodes.NoLiquidity => (HftApiErrorCode.MeNoLiquidity, "No liquidity"),
         MeStatusCodes.NotEnoughFunds => (HftApiErrorCode.MeNotEnoughFunds, "Not enough funds"),
         MeStatusCodes.Dust => (HftApiErrorCode.MeDust, "Dust"),
         MeStatusCodes.ReservedVolumeHigherThanBalance => (HftApiErrorCode.MeReservedVolumeHigherThanBalance, "Reserved volume higher than balance"),
         MeStatusCodes.NotFound => (HftApiErrorCode.MeNotFound, "Not found"),
         MeStatusCodes.BalanceLowerThanReserved => (HftApiErrorCode.MeBalanceLowerThanReserved, "Balance lower than reserved"),
         MeStatusCodes.LeadToNegativeSpread => (HftApiErrorCode.MeLeadToNegativeSpread, "Lead to negative spread"),
         MeStatusCodes.TooSmallVolume => (HftApiErrorCode.MeTooSmallVolume, "Too small volume"),
         MeStatusCodes.InvalidFee => (HftApiErrorCode.MeInvalidFee, "Invalid fee"),
         MeStatusCodes.InvalidPrice => (HftApiErrorCode.MeInvalidPrice, "Invalid price"),
         MeStatusCodes.Replaced => (HftApiErrorCode.MeReplaced, "Replaced"),
         MeStatusCodes.NotFoundPrevious => (HftApiErrorCode.MeNotFoundPrevious, "Not found previous"),
         MeStatusCodes.Duplicate => (HftApiErrorCode.MeDuplicate, "Duplicate"),
         MeStatusCodes.InvalidVolumeAccuracy => (HftApiErrorCode.MeInvalidVolumeAccuracy, "Invalid volume accuracy"),
         MeStatusCodes.InvalidPriceAccuracy => (HftApiErrorCode.MeInvalidPriceAccuracy, "Invalid price accuracy"),
         MeStatusCodes.InvalidVolume => (HftApiErrorCode.MeInvalidVolume, "Invalid volume"),
         MeStatusCodes.TooHighPriceDeviation => (HftApiErrorCode.MeTooHighPriceDeviation, "Too high price deviation"),
         MeStatusCodes.InvalidOrderValue => (HftApiErrorCode.MeInvalidOrderValue, "Invalid order value"),
         MeStatusCodes.Runtime => (HftApiErrorCode.MeRuntime, "ME not available"),
         _ => throw new ArgumentOutOfRangeException(nameof(meCode), meCode, null)
     });
        public static LimitOrderError ToOrderError(this MeStatusCodes meStatusCode)
        {
            switch (meStatusCode)
            {
            case MeStatusCodes.Ok:
                return(LimitOrderError.None);

            case MeStatusCodes.LowBalance:
                return(LimitOrderError.LowBalance);

            case MeStatusCodes.NoLiquidity:
                return(LimitOrderError.NoLiquidity);

            case MeStatusCodes.NotEnoughFunds:
                return(LimitOrderError.NotEnoughFunds);

            case MeStatusCodes.ReservedVolumeHigherThanBalance:
                return(LimitOrderError.ReservedVolumeHigherThanBalance);

            case MeStatusCodes.BalanceLowerThanReserved:
                return(LimitOrderError.BalanceLowerThanReserved);

            case MeStatusCodes.LeadToNegativeSpread:
                return(LimitOrderError.LeadToNegativeSpread);

            case MeStatusCodes.TooSmallVolume:
                return(LimitOrderError.TooSmallVolume);

            case MeStatusCodes.InvalidPrice:
                return(LimitOrderError.InvalidPrice);

            default:
                return(LimitOrderError.Unknown);
            }
        }
コード例 #3
0
 private static void ValidateResponse(MultiLimitOrderResponse response, int expectedCount,
                                      MeStatusCodes expectedStatusCode)
 {
     Assert.NotNull(response);
     Assert.Equal(expectedCount, response.Statuses.Count);
     Assert.True(response.Statuses.All(s => s.Status == expectedStatusCode));
 }
コード例 #4
0
        private ResponseModel <T> ConvertToApiModel <T>(MeStatusCodes status, T result)
        {
            if (status == MeStatusCodes.Ok)
            {
                return(ResponseModel <T> .CreateOk(result));
            }

            var response = ResponseModel <T> .CreateFail(ErrorCodeType.Rejected, status.ToString());

            response.Result = result;
            return(response);
        }
コード例 #5
0
        private OrderStatus MeStatusCodeToOperationsRepositoryOrderStatus(MeStatusCodes code)
        {
            switch (code)
            {
            case MeStatusCodes.Ok:
                return(OrderStatus.InOrderBook);

            case MeStatusCodes.LowBalance:
                return(OrderStatus.NotEnoughFunds);

            case MeStatusCodes.UnknownAsset:
                return(OrderStatus.UnknownAsset);

            case MeStatusCodes.NoLiquidity:
                return(OrderStatus.NoLiquidity);

            case MeStatusCodes.NotEnoughFunds:
                return(OrderStatus.NotEnoughFunds);

            case MeStatusCodes.Dust:
                return(OrderStatus.Dust);

            case MeStatusCodes.ReservedVolumeHigherThanBalance:
                return(OrderStatus.ReservedVolumeGreaterThanBalance);

            case MeStatusCodes.NotFound:
                return(OrderStatus.UnknownAsset);

            case MeStatusCodes.LeadToNegativeSpread:
                return(OrderStatus.LeadToNegativeSpread);

            case MeStatusCodes.TooSmallVolume:
                return(OrderStatus.TooSmallVolume);

            case MeStatusCodes.InvalidFee:
                return(OrderStatus.InvalidFee);

            default:
                throw new ArgumentOutOfRangeException(nameof(code), code, null);
            }
        }
コード例 #6
0
 private static void ValidateResponse(MeResponseModel response, MeStatusCodes expected)
 {
     Assert.NotNull(response);
     Assert.Equal(response.Status, expected);
 }
コード例 #7
0
 private ResponseModel ConvertToApiModel(MeStatusCodes status)
 {
     return(status == MeStatusCodes.Ok
         ? ResponseModel.CreateOk()
         : ResponseModel.CreateFail(ErrorCodeType.Rejected, status.ToString()));
 }