/// <inheritdoc />
 public async Task <IReadOnlyList <IOrder> > ListOrdersAsync(
     ListOrdersRequest request,
     CancellationToken cancellationToken = default) =>
 await _httpClient.GetAsync <IReadOnlyList <IOrder>, List <JsonOrder> >(
     await request.EnsureNotNull(nameof(request))
     .GetUriBuilderAsync(_httpClient).ConfigureAwait(false),
     cancellationToken).ConfigureAwait(false);
        /// <summary>
        /// Gets list of available orders from Alpaca REST API endpoint.
        /// </summary>
        /// <param name="request">List orders request parameters.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>Read-only list of order information objects.</returns>
        public Task <IReadOnlyList <IOrder> > ListOrdersAsync(
            ListOrdersRequest request,
            CancellationToken cancellationToken = default)
        {
            request.EnsureNotNull(nameof(request));

            var builder = new UriBuilder(_httpClient.BaseAddress)
            {
                Path  = _httpClient.BaseAddress.AbsolutePath + "orders",
                Query = new QueryBuilder()
                        .AddParameter("status", request.OrderStatusFilter)
                        .AddParameter("direction", request.OrderListSorting)
                        .AddParameter("until", request.TimeInterval?.Into, "O")
                        .AddParameter("after", request.TimeInterval?.From, "O")
                        .AddParameter("limit", request.LimitOrderNumber)
                        .AddParameter("nested", request.RollUpNestedOrders)
            };

            return(_httpClient.GetObjectsListAsync <IOrder, JsonOrder>(
                       _alpacaRestApiThrottler, builder, cancellationToken));
        }
Esempio n. 3
0
 /// <inheritdoc />
 public Task <IReadOnlyList <IOrder> > ListOrdersAsync(
     ListOrdersRequest request,
     CancellationToken cancellationToken = default) =>
 _httpClient.GetAsync <IReadOnlyList <IOrder>, List <JsonOrder> >(
     request.EnsureNotNull(nameof(request)).GetUriBuilder(_httpClient),
     cancellationToken, _alpacaRestApiThrottler);