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); }
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)); }
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)); }
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)); }
public async Task <TradingRules> GetTradingRules() { var reply = await _restClient.CallAsync(HttpMethod.Get, "/api/v1/exchangeInfo"); return(JsonConvert.DeserializeObject <TradingRules>(reply)); }
public static Task <string> CallAsync(this BinanceRestClient restClient, HttpMethod method, string endpoint) { return(restClient.CallAsync(method, endpoint, null)); }