Show / Hide Table of Contents

Class HistoricalBarsClientExtensions

Set of extension methods for the IHistoricalBarsClient<TRequest> interface.

Inheritance
System.Object
HistoricalBarsClientExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Alpaca.Markets.Extensions
Assembly: Alpaca.Markets.Extensions.dll
Syntax
public static class HistoricalBarsClientExtensions

Methods

| Improve this Doc View Source

GetAverageDailyTradeVolumeAsync<TRequest>(IHistoricalBarsClient<TRequest>, String, IInclusiveTimeInterval)

Gets the average trade volume for the given symbol and timeInterval.

Declaration
public static Task<(Decimal, UInt32)> GetAverageDailyTradeVolumeAsync<TRequest>(this IHistoricalBarsClient<TRequest> client, String symbol, IInclusiveTimeInterval timeInterval)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

String symbol

Asset name for the data retrieval.

IInclusiveTimeInterval timeInterval

Inclusive time interval for the ADTV calculation.

Returns
Type Description
Task<System.ValueTuple<Decimal, UInt32>>

The pair of ADTV value and number of processed day bars.

Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetAverageDailyTradeVolumeAsync<TRequest>(IHistoricalBarsClient<TRequest>, String, IInclusiveTimeInterval, CancellationToken)

Gets the average trade volume for the given symbol and timeInterval.

Declaration
public static Task<(Decimal, UInt32)> GetAverageDailyTradeVolumeAsync<TRequest>(this IHistoricalBarsClient<TRequest> client, String symbol, IInclusiveTimeInterval timeInterval, CancellationToken cancellationToken)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

String symbol

Asset name for the data retrieval.

IInclusiveTimeInterval timeInterval

Inclusive time interval for the ADTV calculation.

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task<System.ValueTuple<Decimal, UInt32>>

The pair of ADTV value and number of processed day bars.

Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetAverageDailyTradeVolumeAsync<TRequest>(IHistoricalBarsClient<TRequest>, String, Interval<DateOnly>)

Gets the average trade volume for the given symbol and timeInterval.

Declaration
public static Task<(Decimal, UInt32)> GetAverageDailyTradeVolumeAsync<TRequest>(this IHistoricalBarsClient<TRequest> client, String symbol, Interval<DateOnly> timeInterval)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

String symbol

Asset name for the data retrieval.

Alpaca.Markets.Interval<DateOnly> timeInterval

Inclusive time interval for the ADTV calculation.

Returns
Type Description
Task<System.ValueTuple<Decimal, UInt32>>

The pair of ADTV value and number of processed day bars.

Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetAverageDailyTradeVolumeAsync<TRequest>(IHistoricalBarsClient<TRequest>, String, Interval<DateOnly>, CancellationToken)

Gets the average trade volume for the given symbol and timeInterval.

Declaration
public static Task<(Decimal, UInt32)> GetAverageDailyTradeVolumeAsync<TRequest>(this IHistoricalBarsClient<TRequest> client, String symbol, Interval<DateOnly> timeInterval, CancellationToken cancellationToken)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

String symbol

Asset name for the data retrieval.

Alpaca.Markets.Interval<DateOnly> timeInterval

Inclusive time interval for the ADTV calculation.

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task<System.ValueTuple<Decimal, UInt32>>

The pair of ADTV value and number of processed day bars.

Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetAverageDailyTradeVolumeAsync<TRequest>(IHistoricalBarsClient<TRequest>, String, DateOnly, DateOnly)

Gets the average trade volume for the given symbol and time interval between from date to the into date (inclusive).

Declaration
public static Task<(Decimal, UInt32)> GetAverageDailyTradeVolumeAsync<TRequest>(this IHistoricalBarsClient<TRequest> client, String symbol, DateOnly from, DateOnly into)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

String symbol

Asset name for the data retrieval.

DateOnly from

Filter data equal to or after this time.

DateOnly into

Filter data equal to or before this time.

Returns
Type Description
Task<System.ValueTuple<Decimal, UInt32>>

The pair of ADTV value and number of processed day bars.

Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetAverageDailyTradeVolumeAsync<TRequest>(IHistoricalBarsClient<TRequest>, String, DateOnly, DateOnly, CancellationToken)

Gets the average trade volume for the given symbol and time interval between from date to the into date (inclusive).

Declaration
public static Task<(Decimal, UInt32)> GetAverageDailyTradeVolumeAsync<TRequest>(this IHistoricalBarsClient<TRequest> client, String symbol, DateOnly from, DateOnly into, CancellationToken cancellationToken)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

String symbol

Asset name for the data retrieval.

DateOnly from

Filter data equal to or after this time.

DateOnly into

Filter data equal to or before this time.

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task<System.ValueTuple<Decimal, UInt32>>

The pair of ADTV value and number of processed day bars.

Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetAverageDailyTradeVolumeAsync<TRequest>(IHistoricalBarsClient<TRequest>, String, DateTime, DateTime)

Gets the average trade volume for the given symbol and time interval between from date to the into date (inclusive).

Declaration
public static Task<(Decimal, UInt32)> GetAverageDailyTradeVolumeAsync<TRequest>(this IHistoricalBarsClient<TRequest> client, String symbol, DateTime from, DateTime into)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

String symbol

Asset name for the data retrieval.

DateTime from

Filter data equal to or after this time.

DateTime into

Filter data equal to or before this time.

Returns
Type Description
Task<System.ValueTuple<Decimal, UInt32>>

The pair of ADTV value and number of processed day bars.

Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetAverageDailyTradeVolumeAsync<TRequest>(IHistoricalBarsClient<TRequest>, String, DateTime, DateTime, CancellationToken)

Gets the average trade volume for the given symbol and time interval between from date to the into date (inclusive).

Declaration
public static Task<(Decimal, UInt32)> GetAverageDailyTradeVolumeAsync<TRequest>(this IHistoricalBarsClient<TRequest> client, String symbol, DateTime from, DateTime into, CancellationToken cancellationToken)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

String symbol

Asset name for the data retrieval.

DateTime from

Filter data equal to or after this time.

DateTime into

Filter data equal to or before this time.

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
Task<System.ValueTuple<Decimal, UInt32>>

The pair of ADTV value and number of processed day bars.

Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetHistoricalBarsAsAsyncEnumerable<TRequest>(IHistoricalBarsClient<TRequest>, TRequest)

Gets all items provided by Alpaca.Markets.IHistoricalBarsClient`1.ListHistoricalBarsAsync(`0,System.Threading.CancellationToken) in pagination mode as single stream of items (in form of interface) so they can be consumed by the await foreach statement on the caller side.

Declaration
public static IAsyncEnumerable<IBar> GetHistoricalBarsAsAsyncEnumerable<TRequest>(this IHistoricalBarsClient<TRequest> client, TRequest request)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

TRequest request

Original historical bars request (with empty next page token).

Returns
Type Description
IAsyncEnumerable<IBar>
Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RequestValidationException

The request argument contains invalid data or some required data is missing, unable to create a valid HTTP request.

RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetHistoricalBarsAsAsyncEnumerable<TRequest>(IHistoricalBarsClient<TRequest>, TRequest, CancellationToken)

Gets all items provided by Alpaca.Markets.IHistoricalBarsClient`1.ListHistoricalBarsAsync(`0,System.Threading.CancellationToken) in pagination mode as single stream of items (in form of interface) so they can be consumed by the await foreach statement on the caller side.

Declaration
public static IAsyncEnumerable<IBar> GetHistoricalBarsAsAsyncEnumerable<TRequest>(this IHistoricalBarsClient<TRequest> client, TRequest request, CancellationToken cancellationToken)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

TRequest request

Original historical bars request (with empty next page token).

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
IAsyncEnumerable<IBar>
Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RequestValidationException

The request argument contains invalid data or some required data is missing, unable to create a valid HTTP request.

RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetHistoricalBarsDictionaryOfAsyncEnumerable<TRequest>(IHistoricalBarsClient<TRequest>, TRequest)

Gets all items provided by Alpaca.Markets.IHistoricalBarsClient`1.GetHistoricalBarsAsync(`0,System.Threading.CancellationToken) in pagination mode as single stream of items (in form of dictionary of the interface instances) so they can be consumed by the await foreach statement on the caller side.

Declaration
public static IReadOnlyDictionary<String, IAsyncEnumerable<IBar>> GetHistoricalBarsDictionaryOfAsyncEnumerable<TRequest>(this IHistoricalBarsClient<TRequest> client, TRequest request)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

TRequest request

Original historical bars request (with empty next page token).

Returns
Type Description
IReadOnlyDictionary<String, IAsyncEnumerable<IBar>>
Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RequestValidationException

The request argument contains invalid data or some required data is missing, unable to create a valid HTTP request.

RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetHistoricalBarsDictionaryOfAsyncEnumerable<TRequest>(IHistoricalBarsClient<TRequest>, TRequest, CancellationToken)

Gets all items provided by Alpaca.Markets.IHistoricalBarsClient`1.GetHistoricalBarsAsync(`0,System.Threading.CancellationToken) in pagination mode as single stream of items (in form of dictionary of the interface instances) so they can be consumed by the await foreach statement on the caller side.

Declaration
public static IReadOnlyDictionary<String, IAsyncEnumerable<IBar>> GetHistoricalBarsDictionaryOfAsyncEnumerable<TRequest>(this IHistoricalBarsClient<TRequest> client, TRequest request, CancellationToken cancellationToken)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

TRequest request

Original historical bars request (with empty next page token).

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
IReadOnlyDictionary<String, IAsyncEnumerable<IBar>>
Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RequestValidationException

The request argument contains invalid data or some required data is missing, unable to create a valid HTTP request.

RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetHistoricalBarsMultiPagesAsAsyncEnumerable<TRequest>(IHistoricalBarsClient<TRequest>, TRequest)

Gets all items provided by Alpaca.Markets.IHistoricalBarsClient`1.GetHistoricalBarsAsync(`0,System.Threading.CancellationToken) in pagination mode as single stream of response pages with items so they can be consumed by the await foreach statement on the caller side as sequence of 'batches' instead of sequence of items itself.

Declaration
public static IAsyncEnumerable<IReadOnlyDictionary<String, IReadOnlyList<IBar>>> GetHistoricalBarsMultiPagesAsAsyncEnumerable<TRequest>(this IHistoricalBarsClient<TRequest> client, TRequest request)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

TRequest request

Original historical bars request (with empty next page token).

Returns
Type Description
IAsyncEnumerable<IReadOnlyDictionary<String, IReadOnlyList<IBar>>>
Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RequestValidationException

The request argument contains invalid data or some required data is missing, unable to create a valid HTTP request.

RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetHistoricalBarsMultiPagesAsAsyncEnumerable<TRequest>(IHistoricalBarsClient<TRequest>, TRequest, CancellationToken)

Gets all items provided by Alpaca.Markets.IHistoricalBarsClient`1.GetHistoricalBarsAsync(`0,System.Threading.CancellationToken) in pagination mode as single stream of response pages with items so they can be consumed by the await foreach statement on the caller side as sequence of 'batches' instead of sequence of items itself.

Declaration
public static IAsyncEnumerable<IReadOnlyDictionary<String, IReadOnlyList<IBar>>> GetHistoricalBarsMultiPagesAsAsyncEnumerable<TRequest>(this IHistoricalBarsClient<TRequest> client, TRequest request, CancellationToken cancellationToken)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

TRequest request

Original historical bars request (with empty next page token).

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
IAsyncEnumerable<IReadOnlyDictionary<String, IReadOnlyList<IBar>>>
Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RequestValidationException

The request argument contains invalid data or some required data is missing, unable to create a valid HTTP request.

RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetHistoricalBarsPagesAsAsyncEnumerable<TRequest>(IHistoricalBarsClient<TRequest>, TRequest)

Gets all items provided by Alpaca.Markets.IHistoricalBarsClient`1.ListHistoricalBarsAsync(`0,System.Threading.CancellationToken) in pagination mode as single stream of response pages with items so they can be consumed by the await foreach statement on the caller side as sequence of 'batches' instead of sequence of items itself.

Declaration
public static IAsyncEnumerable<IReadOnlyList<IBar>> GetHistoricalBarsPagesAsAsyncEnumerable<TRequest>(this IHistoricalBarsClient<TRequest> client, TRequest request)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

TRequest request

Original historical bars request (with empty next page token).

Returns
Type Description
IAsyncEnumerable<IReadOnlyList<IBar>>
Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RequestValidationException

The request argument contains invalid data or some required data is missing, unable to create a valid HTTP request.

RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetHistoricalBarsPagesAsAsyncEnumerable<TRequest>(IHistoricalBarsClient<TRequest>, TRequest, CancellationToken)

Gets all items provided by Alpaca.Markets.IHistoricalBarsClient`1.ListHistoricalBarsAsync(`0,System.Threading.CancellationToken) in pagination mode as single stream of response pages with items so they can be consumed by the await foreach statement on the caller side as sequence of 'batches' instead of sequence of items itself.

Declaration
public static IAsyncEnumerable<IReadOnlyList<IBar>> GetHistoricalBarsPagesAsAsyncEnumerable<TRequest>(this IHistoricalBarsClient<TRequest> client, TRequest request, CancellationToken cancellationToken)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

TRequest request

Original historical bars request (with empty next page token).

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
IAsyncEnumerable<IReadOnlyList<IBar>>
Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RequestValidationException

The request argument contains invalid data or some required data is missing, unable to create a valid HTTP request.

RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

| Improve this Doc View Source

GetSimpleMovingAverageAsync<TRequest>(IHistoricalBarsClient<TRequest>, TRequest, Int32)

Gets the simple moving average values for the given list of IBar objects.

Declaration
public static IAsyncEnumerable<IBar> GetSimpleMovingAverageAsync<TRequest>(this IHistoricalBarsClient<TRequest> client, TRequest request, Int32 window)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

TRequest request

Original historical minute bars request (with empty next page token).

Int32 window

Size of the moving average window.

Returns
Type Description
IAsyncEnumerable<IBar>

The list of bars with SMA values for all IBar properties.

Type Parameters
Name Description
TRequest
| Improve this Doc View Source

GetSimpleMovingAverageAsync<TRequest>(IHistoricalBarsClient<TRequest>, TRequest, Int32, CancellationToken)

Gets the simple moving average values for the given list of IBar objects.

Declaration
public static IAsyncEnumerable<IBar> GetSimpleMovingAverageAsync<TRequest>(this IHistoricalBarsClient<TRequest> client, TRequest request, Int32 window, CancellationToken cancellationToken)
    where TRequest : HistoricalRequestBase, IHistoricalRequest<TRequest, IBar>
Parameters
Type Name Description
IHistoricalBarsClient<TRequest> client

Target instance of the IHistoricalBarsClient<TRequest> interface.

TRequest request

Original historical minute bars request (with empty next page token).

Int32 window

Size of the moving average window.

CancellationToken cancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns
Type Description
IAsyncEnumerable<IBar>

The list of bars with SMA values for all IBar properties.

Type Parameters
Name Description
TRequest
Exceptions
Type Condition
RequestValidationException

The request argument contains invalid data or some required data is missing, unable to create a valid HTTP request.

RestClientErrorException

The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX