infrastructure.providers.alpaca.api.transactions_api¶
src.infrastructure.providers.alpaca.api.transactions_api
¶
Alpaca Transactions API client.
HTTP client for Alpaca Trading API account activities endpoint. Uses API Key authentication headers.
Endpoints
GET /v2/account/activities - Get account activities (Alpaca's term for transactions)
Activity Types
FILL - Order fill (trade execution) DIV - Dividend DIVCGL/DIVCGS/DIVNRA/DIVFT/DIVTXEX - Various dividend types INT - Interest JNLC - Journal entry (cash) JNLS - Journal entry (stock) MA - Merger/Acquisition NC - Name change PTC - Pass-through charge REO - Reorg fee SC - Symbol change SSO - Stock spinoff SSP - Stock split
Reference
- https://docs.alpaca.markets/reference/getaccountactivities-1
Attributes¶
Classes¶
AlpacaTransactionsAPI
¶
Bases: BaseProviderAPIClient
HTTP client for Alpaca Trading API transactions (activities) endpoint.
Uses API Key authentication (not OAuth Bearer tokens). Returns raw JSON responses - mapping to domain types is done by mappers.
Note: Alpaca calls transactions "activities" in their API.
Attributes:
| Name | Type | Description |
|---|---|---|
base_url |
Alpaca Trading API base URL (paper or live). |
|
timeout |
HTTP request timeout in seconds. |
Example
api = AlpacaTransactionsAPI( ... base_url="https://paper-api.alpaca.markets", ... timeout=30.0, ... ) result = await api.get_transactions(api_key="...", api_secret="...")
Source code in src/infrastructure/providers/alpaca/api/transactions_api.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
Functions¶
__init__
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
Alpaca Trading API base URL. |
required |
timeout
|
float
|
HTTP request timeout in seconds. |
PROVIDER_TIMEOUT_DEFAULT
|
Source code in src/infrastructure/providers/alpaca/api/transactions_api.py
get_transactions
async
¶
get_transactions(
api_key: str,
api_secret: str,
*,
activity_types: list[str] | None = None,
start_date: date | None = None,
end_date: date | None = None,
page_size: int = 100
) -> Result[list[dict[str, Any]], ProviderError]
Fetch account transactions (called 'activities' in Alpaca API).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
Alpaca API Key ID. |
required |
api_secret
|
str
|
Alpaca API Secret Key. |
required |
activity_types
|
list[str] | None
|
Filter by Alpaca activity types (e.g., ["FILL", "DIV"]). |
None
|
start_date
|
date | None
|
Get transactions after this date. |
None
|
end_date
|
date | None
|
Get transactions until this date. |
None
|
page_size
|
int
|
Number of transactions per page (max 100). |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
Success |
list[dict]
|
List of transaction JSON objects. |
Failure |
ProviderAuthenticationError
|
If credentials are invalid. |
Failure |
ProviderUnavailableError
|
If Alpaca API is unreachable. |