/// <summary> /// Get historical trades /// </summary> /// <param name="symoblName"></param> /// <param name="sort">Sort direction</param> /// <param name="by">Filter field</param> /// <param name="from">If filter by timestamp, then datetime in iso format or timestamp in millisecond otherwise trade id</param> /// <param name="till">If filter by timestamp, then datetime in iso format or timestamp in millisecond otherwise trade id</param> /// <param name="offset"></param> /// <param name="limit"></param> /// <returns></returns> public async Task <List <TradeHistory> > GetTraders(string symoblName, string from, string till, int offset, int limit = 100, PublicEnum.EnSort sort = PublicEnum.EnSort.Desc, PublicEnum.EnBy by = PublicEnum.EnBy.timestamp) { var request = new RestRequest("/api/2/history/trades"); if (!string.IsNullOrEmpty(symoblName)) { request.Parameters.Add(new Parameter("symbol", symoblName, ParameterType.GetOrPost)); } request.Parameters.Add(new Parameter("sort", sort.ToString(), ParameterType.GetOrPost)); request.Parameters.Add(new Parameter("by", by.ToString(), ParameterType.GetOrPost)); if (!string.IsNullOrEmpty(from)) { request.Parameters.Add(new Parameter("from", from, ParameterType.GetOrPost)); } if (!string.IsNullOrEmpty(till)) { request.Parameters.Add(new Parameter("till", till, ParameterType.GetOrPost)); } if (offset > 0) { request.Parameters.Add(new Parameter("offset", offset, ParameterType.GetOrPost)); } if (limit > 0) { request.Parameters.Add(new Parameter("limit", limit, ParameterType.GetOrPost)); } return(await _hitBtcRestApi.Execute(request)); }
/// <summary> /// get transaction by transaction id /// Requires the "Payment information" API key permission. /// </summary> /// <param name="transactionId"></param> /// <param name="currency"></param> /// <param name="from"></param> /// <param name="till"></param> /// <param name="offset"></param> /// <param name="limit"></param> /// <param name="sort"></param> /// <param name="by"></param> /// <returns></returns> public async Task <List <Transaction> > GetTransaction(string transactionId, string currency, string from, string till, int offset, int limit = 100, PublicEnum.EnSort sort = PublicEnum.EnSort.Desc, PublicEnum.EnBy by = PublicEnum.EnBy.timestamp) { var request = new RestRequest("/api/2/account/transactions/{id}", Method.GET); request.AddParameter("id", transactionId, ParameterType.UrlSegment); if (!string.IsNullOrEmpty(currency)) { request.AddParameter("currency", currency, ParameterType.UrlSegment); } request.AddParameter("sort", sort.ToString(), ParameterType.UrlSegment); request.AddParameter("by", by.ToString(), ParameterType.UrlSegment); if (!string.IsNullOrEmpty(from)) { request.AddParameter("from", from, ParameterType.UrlSegment); } if (!string.IsNullOrEmpty(till)) { request.AddParameter("till", till, ParameterType.UrlSegment); } if (limit > 0) { request.AddParameter("limit", limit, ParameterType.UrlSegment); } if (offset > 0) { request.AddParameter("offset", offset, ParameterType.UrlSegment); } return(await _hitBtcRestApi.Execute(request)); }
/// <summary> /// Get historical trades /// </summary> /// <param name="symoblName"></param> /// <param name="sort">Sort direction</param> /// <param name="by">Filter field</param> /// <param name="from">If filter by timestamp, then datetime in iso format or timestamp in millisecond otherwise trade id</param> /// <param name="till">If filter by timestamp, then datetime in iso format or timestamp in millisecond otherwise trade id</param> /// <param name="offset"></param> /// <param name="id"></param> /// <param name="limit"></param> /// <returns></returns> public async Task <SocketTrades> GetTrades(string symoblName, string from, string till, int offset, int id = 123, int limit = 100, PublicEnum.EnSort sort = PublicEnum.EnSort.Desc, PublicEnum.EnBy by = PublicEnum.EnBy.timestamp) { string[] paramterArray = new string[7]; if (!string.IsNullOrEmpty(symoblName)) { paramterArray[0] = string.Format("\"symbol\": \"{0}\"", symoblName); } paramterArray[1] = string.Format("\"sort\": \"{0}\"", sort.ToString()); paramterArray[2] = string.Format("\"by\": \"{0}\"", by.ToString()); if (!string.IsNullOrEmpty(from)) { paramterArray[3] = string.Format("\"from\": \"{0}\"", from); } if (!string.IsNullOrEmpty(till)) { paramterArray[4] = string.Format("\"till\": \"{0}\"", till); } if (limit > 0) { paramterArray[5] = string.Format("\"limit\": \"{0}\"", limit.ToString()); } if (offset > 0) { paramterArray[6] = string.Format("\"offset\": \"{0}\"", offset.ToString()); } string parameters = string.Empty; for (var index = 0; index < paramterArray.Length - 1; index++) { if (!string.IsNullOrEmpty(paramterArray[index])) { parameters += paramterArray[index] + " , "; } } if (!string.IsNullOrEmpty(paramterArray[6])) { parameters += paramterArray[6]; } var request = string.Format("{{ \"method\": \"getTrades\", \"params\": {{ {0} }}, \"id\": {1} }}", parameters, id); return(await _hitBtcSocketApi.Execute(request, false)); }