/// <summary> /// Gets a list of orders /// </summary> /// <param name="accountId">The account id to get orders for</param> /// <param name="symbol">The symbol to get orders for</param> /// <param name="states">The states of orders to return</param> /// <param name="types">The types of orders to return</param> /// <param name="startTime">Only get orders after this date</param> /// <param name="endTime">Only get orders before this date</param> /// <param name="fromId">Only get orders with id's higher than this</param> /// <param name="limit">The max number of results</param> /// <returns></returns> public async Task <CallResult <List <HuobiOrder> > > QueryOrdersAsync(long accountId, string symbol, HuobiOrderState[] states, HuobiOrderType[] types = null, DateTime?startTime = null, DateTime?endTime = null, long?fromId = null, int?limit = null) { var stateConverter = new OrderStateConverter(false); var stateString = string.Join(",", states.Select(s => JsonConvert.SerializeObject(s, stateConverter))); var request = new HuobiOrderListRequest(accountId, symbol, stateString); if (types != null) { var typeConverter = new OrderTypeConverter(false); request.Types = string.Join(",", types.Select(s => JsonConvert.SerializeObject(s, typeConverter))); } request.StartTime = startTime?.ToString("yyyy-MM-dd"); request.EndTime = endTime?.ToString("yyyy-MM-dd"); request.FromId = fromId?.ToString(); request.Limit = limit?.ToString(); var result = await Query <HuobiSocketAuthDataResponse <List <HuobiOrder> > >(request).ConfigureAwait(false); return(new CallResult <List <HuobiOrder> >(result.Data?.Data, result.Error)); }
/// <summary> /// Gets a list of orders /// </summary> /// <param name="accountId">The account id to get orders for</param> /// <param name="symbol">The symbol to get orders for</param> /// <param name="states">The states of orders to return</param> /// <param name="types">The types of orders to return</param> /// <param name="startTime">Only get orders after this date</param> /// <param name="endTime">Only get orders before this date</param> /// <param name="fromId">Only get orders with id's higher than this</param> /// <param name="limit">The max number of results</param> /// <returns></returns> public async Task <CallResult <IEnumerable <HuobiOrder> > > GetOrdersAsync(long accountId, string symbol, IEnumerable <HuobiOrderState> states, IEnumerable <HuobiOrderType>?types = null, DateTime?startTime = null, DateTime?endTime = null, long?fromId = null, int?limit = null) { symbol = symbol.ValidateHuobiSymbol(); var stateConverter = new OrderStateConverter(false); var stateString = string.Join(",", states.Select(s => JsonConvert.SerializeObject(s, stateConverter))); var request = new HuobiOrderListRequest(NextId().ToString(CultureInfo.InvariantCulture), accountId, symbol, stateString); if (types != null) { var typeConverter = new OrderTypeConverter(false); request.Types = string.Join(",", types.Select(s => JsonConvert.SerializeObject(s, typeConverter))); } request.StartTime = startTime?.ToString("yyyy-MM-dd"); request.EndTime = endTime?.ToString("yyyy-MM-dd"); request.FromId = fromId?.ToString(CultureInfo.InvariantCulture); request.Limit = limit?.ToString(CultureInfo.InvariantCulture); var result = await Query <HuobiSocketAuthDataResponse <IEnumerable <HuobiOrder> > >(request, true).ConfigureAwait(false); return(new CallResult <IEnumerable <HuobiOrder> >(result.Data?.Data, result.Error)); }