[Bug]: ActivityType enum missing CGD (Capital Gain Distribution)
- Langage dominant
- Python
- Étoiles
- 1.5k
- Forks
- 398
- Merge moyen
- 1 j 16 h
- PR mergées (30 j)
- 6
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Current Behavior
The Alpaca Broker API returns activities with "activity_type": "CGD" (Capital Gain Distribution), and the public API docs list CGD as a valid enumActivityType value: https://docs.alpaca.markets/reference/getaccountactivities. However, CGD is not present in the SDK's ActivityType enum ([alpaca/trading/enums.py](https://github.com/alpacahq/alpaca-py/blob/master/alpaca/trading/enums.py))
This is causing two specific problems:
1. Validation problem:
`NonTradeActivity.model_validate(...)` raises on any real CGD activity returned by the broker API — making the SDK's response models unusable for these payloads.
2. Request payload problem
`GetAccountActivitiesRequest(activity_types=[...])` cannot be constructed to filter for CGDs, because the field is typed against ActivityType.
Workaround is to bypass the request model and pass "CGD" as a raw query parameter to BrokerClient.get("/accounts/activities/", data=...).
### Expected Behavior
Add CGD = "CGD" to alpaca/trading/enums.py::ActivityType.
### SDK Version I encountered this issue in
0.43.4
### Steps To Reproduce
```markdown
from alpaca.trading.models import NonTradeActivity
raw = {
"id": "20260525000000000::c524b737-b67b-416a-b451-321e42d3a609",
"account_id": "c524b737-b67b-416a-b451-321e42d3a609",
"activity_type": "CGD",
"activity_sub_type": "STCG",
"date": "2026-05-25",
"net_amount": "0.18",
"symbol": "AIA",
"status": "executed",
"currency": "USD",
}
NonTradeActivity.model_validate(raw)
# Will raise an incorrect validation error
# pydantic_core._pydantic_core.ValidationError: 2 validation errors for NonTradeActivity activity_type
# Input should be 'FILL', 'ACATC', 'ACATS', 'CFEE', 'CIL', 'CSD', 'CSW', 'DIV', 'DIVCGL', 'DIVCGS', 'DIVNRA', 'DIVROC', 'DIVTXEX', 'DIVWH', 'EXTRD', 'FEE', 'FXTRD', 'INT', 'INTPNL', 'JNLC', 'JNLS', 'MA', 'MEM', 'NC', 'OCT', 'OPASN', 'OPCSH', 'OPEXC', 'OPEXP', 'OPTRD', 'PTC', 'REORG', 'SPIN', 'SPLIT', 'SWP', 'VOF' or 'WH' [type=enum, input_value='CGD', input_type=str]
```
### Filled out the Steps to Reproduce section?
- [x] I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.
### Anything else?
_No response_
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.