Beispiel #1
0
        /// <summary>
        ///     Processes a PUT request
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="endpoint"></param>
        /// <param name="receiveWindow"></param>
        /// <returns></returns>
        public async Task <T> ProcessPutRequest <T>(BinanceEndpointData endpoint, int receiveWindow = 5000)
            where T : class
        {
            var fullKey = $"{typeof(T).Name}-{endpoint.Uri.AbsoluteUri}";

            HttpResponseMessage message;

            switch (endpoint.SecurityType)
            {
            case EndpointSecurityType.ApiKey:
                message = await RequestClient.PutRequest(endpoint.Uri);

                break;

            case EndpointSecurityType.None:
            case EndpointSecurityType.Signed:
            default:
                throw new ArgumentOutOfRangeException();
            }

            return(await HandleResponse <T>(message, endpoint.ToString(), fullKey));
        }
Beispiel #2
0
        /// <summary>
        /// Create a new Binance Client based on the configuration provided
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="apiCache"></param>
        public BinanceClient(ClientConfiguration configuration, IAPIProcessor apiProcessor = null)
        {
            _logger = configuration.Logger ?? LogManager.GetCurrentClassLogger();
            Guard.AgainstNull(configuration);
            Guard.AgainstNullOrEmpty(configuration.ApiKey);
            Guard.AgainstNull(configuration.SecretKey);

            _apiKey    = configuration.ApiKey;
            _secretKey = configuration.SecretKey;

            RequestClient.SetRateLimiting(configuration.EnableRateLimiting);
            RequestClient.SetAPIKey(_apiKey);
            if (apiProcessor == null)
            {
                _apiProcessor = new APIProcessor(_apiKey, _secretKey, new APICacheManager());
                _apiProcessor.SetCacheTime(configuration.CacheTime);
            }
            else
            {
                _apiProcessor = apiProcessor;
            }
        }