コード例 #1
0
        public async Task <WithdrawHistory> GetWithdrawHistory(DateTime startDate)
        {
            var toReturn = new WithdrawHistory {
                Success = true, WithdrawList = new List <Withdraw>()
            };

            while (true)
            {
                if (startDate > DateTime.Today)
                {
                    break;
                }

                DateTime endDate    = startDate.AddDays(90);
                var      parameters = $"startTime={startDate.ToUnixDateTime()}&endTime={endDate.ToUnixDateTime()}";
                parameters = _restClient.AddTimestampAndSign(parameters);
                var result = await _restClient.CallAsync(HttpMethod.Get, "/wapi/v3/withdrawHistory.html", parameters);

                var resultTyped = JsonConvert.DeserializeObject <WithdrawHistory>(result);

                if (!resultTyped.Success)
                {
                    throw new Exception();
                }

                toReturn.WithdrawList.AddRange(resultTyped.WithdrawList ?? Enumerable.Empty <Withdraw>());
                startDate = endDate.AddDays(1);
            }

            return(toReturn);
        }
コード例 #2
0
        public async Task <IList <Trade> > GetMyTrades(string symbol, int id)
        {
            var parameters = $"symbol={symbol}&limit=1000&fromId={id}";

            parameters = _restClient.AddTimestampAndSign(parameters);
            var reply = await _restClient.CallAsync(HttpMethod.Get, "/api/v3/myTrades", parameters);

            return(JsonConvert.DeserializeObject <IList <Trade> >(reply));
        }
コード例 #3
0
        public async Task <AccountInfo> GetAccountInfo()
        {
            var parameters = $"recvWindow=60000";

            parameters = _restClient.AddTimestampAndSign(parameters);

            var reply = await _restClient.CallAsync(HttpMethod.Get, "/api/v3/account", parameters);

            return(JsonConvert.DeserializeObject <AccountInfo>(reply));
        }
コード例 #4
0
        public async Task <Candlestick[]> GetCandlesticks(string symbol, TimeInterval timeInterval, long?start = null, long?end = null, int?limit = null)
        {
            var parameters = $"symbol={symbol}&interval={timeInterval.GetDescription()}";

            if (start.HasValue)
            {
                parameters += $"&startTime={start.Value}";
            }
            if (end.HasValue)
            {
                parameters += $"&endTime={end.Value}";
            }
            if (limit.HasValue)
            {
                parameters += $"&limit={limit.Value}";
            }

            var reply = await _restClient.CallAsync(HttpMethod.Get, "/api/v3/klines", parameters);

            return(Convert(reply));
        }
コード例 #5
0
        public async Task <TradingRules> GetTradingRules()
        {
            var reply = await _restClient.CallAsync(HttpMethod.Get, "/api/v1/exchangeInfo");

            return(JsonConvert.DeserializeObject <TradingRules>(reply));
        }
コード例 #6
0
 public static Task <string> CallAsync(this BinanceRestClient restClient, HttpMethod method, string endpoint)
 {
     return(restClient.CallAsync(method, endpoint, null));
 }