Show / Hide Table of Contents

Class AlpacaTradingClientExtensions

Set of extension methods for the IAlpacaTradingClient interface.

Inheritance
System.Object
AlpacaTradingClientExtensions
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 AlpacaTradingClientExtensions

Methods

| Improve this Doc View Source

GetCalendarForSingleDayAsync(IAlpacaTradingClient, DateOnly, CancellationToken)

Get single trading day information from the Alpaca REST API.

Declaration
public static async Task<IIntervalCalendar> GetCalendarForSingleDayAsync(this IAlpacaTradingClient client, DateOnly date, CancellationToken cancellationToken = null)
Parameters
Type Name Description
IAlpacaTradingClient client

The IAlpacaDataClient object instance.

DateOnly date

The trading date (time part will not be used).

CancellationToken cancellationToken

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

Returns
Type Description
Task<IIntervalCalendar>

Read-only trading date information object.

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

GetCalendarForSingleDayAsync(IAlpacaTradingClient, DateTime, CancellationToken)

Get single trading day information from the Alpaca REST API.

Declaration
public static async Task<ICalendar> GetCalendarForSingleDayAsync(this IAlpacaTradingClient client, DateTime date, CancellationToken cancellationToken = null)
Parameters
Type Name Description
IAlpacaTradingClient client

The IAlpacaDataClient object instance.

DateTime date

The trading date (time part will not be used).

CancellationToken cancellationToken

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

Returns
Type Description
Task<ICalendar>

Read-only trading date information object.

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

GetClockCachedAsync(IAlpacaTradingClient)

Gets the cached IClock instance with the current session state.

Declaration
public static ValueTask<IClock> GetClockCachedAsync(this IAlpacaTradingClient client)
Parameters
Type Name Description
IAlpacaTradingClient client

The IAlpacaDataClient object instance.

Returns
Type Description
ValueTask<IClock>

Cached or value of IClock instance or result of REST API call.

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

GetClockCachedAsync(IAlpacaTradingClient, CancellationToken)

Gets the cached IClock instance with the current session state.

Declaration
public static async ValueTask<IClock> GetClockCachedAsync(this IAlpacaTradingClient client, CancellationToken cancellationToken)
Parameters
Type Name Description
IAlpacaTradingClient client

The IAlpacaDataClient object instance.

CancellationToken cancellationToken

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

Returns
Type Description
ValueTask<IClock>

Cached or value of IClock instance or result of REST API call.

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

IsMarketOpenAsync(IAlpacaTradingClient)

Gets the IsOpen state from cached API result call.

Declaration
public static ValueTask<Boolean> IsMarketOpenAsync(this IAlpacaTradingClient client)
Parameters
Type Name Description
IAlpacaTradingClient client

The IAlpacaDataClient object instance.

Returns
Type Description
ValueTask<Boolean>

If trading day is open now returns true value.

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

IsMarketOpenAsync(IAlpacaTradingClient, CancellationToken)

Gets the IsOpen state from cached API result call.

Declaration
public static async ValueTask<Boolean> IsMarketOpenAsync(this IAlpacaTradingClient client, CancellationToken cancellationToken)
Parameters
Type Name Description
IAlpacaTradingClient client

The IAlpacaDataClient object instance.

CancellationToken cancellationToken

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

Returns
Type Description
ValueTask<Boolean>

If trading day is open now returns true value.

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

ListAccountActivitiesAsAsyncEnumerable(IAlpacaTradingClient, AccountActivitiesRequest)

Gets all account activities from Alpaca REST API endpoint as async enumerable stream.

Declaration
public static IAsyncEnumerable<IAccountActivity> ListAccountActivitiesAsAsyncEnumerable(this IAlpacaTradingClient client, AccountActivitiesRequest request)
Parameters
Type Name Description
IAlpacaTradingClient client

The IAlpacaTradingClient object instance.

AccountActivitiesRequest request

Account activities request parameters.

Returns
Type Description
IAsyncEnumerable<IAccountActivity>

Account activity record objects obtained page by page.

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

ListAccountActivitiesAsAsyncEnumerable(IAlpacaTradingClient, AccountActivitiesRequest, CancellationToken)

Gets all account activities from Alpaca REST API endpoint as async enumerable stream.

Declaration
public static IAsyncEnumerable<IAccountActivity> ListAccountActivitiesAsAsyncEnumerable(this IAlpacaTradingClient client, AccountActivitiesRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
IAlpacaTradingClient client

The IAlpacaTradingClient object instance.

AccountActivitiesRequest request

Account activities request parameters.

CancellationToken cancellationToken

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

Returns
Type Description
IAsyncEnumerable<IAccountActivity>

Account activity record objects obtained page by page.

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

ListOptionContractsAsAsyncEnumerable(IAlpacaTradingClient, OptionContractsRequest)

Gets all option contracts from Alpaca REST API endpoint as async enumerable stream.

Declaration
public static IAsyncEnumerable<IOptionContract> ListOptionContractsAsAsyncEnumerable(this IAlpacaTradingClient client, OptionContractsRequest request)
Parameters
Type Name Description
IAlpacaTradingClient client

The IAlpacaTradingClient object instance.

OptionContractsRequest request

Account activities request parameters.

Returns
Type Description
IAsyncEnumerable<IOptionContract>

Account activity record objects obtained page by page.

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

ListOptionContractsAsAsyncEnumerable(IAlpacaTradingClient, OptionContractsRequest, CancellationToken)

Gets all option contracts from Alpaca REST API endpoint as async enumerable stream.

Declaration
public static IAsyncEnumerable<IOptionContract> ListOptionContractsAsAsyncEnumerable(this IAlpacaTradingClient client, OptionContractsRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
IAlpacaTradingClient client

The IAlpacaTradingClient object instance.

OptionContractsRequest request

Account activities request parameters.

CancellationToken cancellationToken

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

Returns
Type Description
IAsyncEnumerable<IOptionContract>

Account activity record objects obtained page by page.

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