Class AlpacaTradingClientExtensions
Set of extension methods for the IAlpacaTradingClient interface.
Inheritance
Inherited Members
Namespace: Alpaca.Markets.Extensions
Assembly: Alpaca.Markets.Extensions.dll
Syntax
public static class AlpacaTradingClientExtensions
Methods
| Improve this Doc View SourceGetCalendarForSingleDayAsync(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. |
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. |
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. |
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. |
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 |
Exceptions
Type | Condition |
---|---|
RestClientErrorException | The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch. |
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 |
Exceptions
Type | Condition |
---|---|
RestClientErrorException | The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch. |
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 |
RestClientErrorException | The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch. |
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 |
RestClientErrorException | The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch. |
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 |
RestClientErrorException | The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch. |
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 |
RestClientErrorException | The response contains an error message or the received response cannot be deserialized properly due to JSON schema mismatch. |