diff --git a/alpaca/broker/client.py b/alpaca/broker/client.py index df4beac1..7be97963 100644 --- a/alpaca/broker/client.py +++ b/alpaca/broker/client.py @@ -5,6 +5,7 @@ from pydantic import parse_obj_as from requests import HTTPError, Response +from .enums import ACHRelationshipStatus from .constants import BROKER_DOCUMENT_UPLOAD_LIMIT from .models import ( Account, @@ -18,6 +19,7 @@ TradeAccount, TradeDocument, UploadDocumentRequest, + ACHRelationship, ) from ..common import APIError from ..common.constants import ACCOUNT_ACTIVITIES_DEFAULT_PAGE_SIZE @@ -589,3 +591,10 @@ def download_trade_document_for_account_by_id( f.write(chunk) # ############################## FUNDING ################################# # + + def get_ach_relationships_for_account( + self, + account_id: Union[UUID, str], + statuses: Optional[List[ACHRelationshipStatus]], + ) -> List[ACHRelationship]: + pass diff --git a/alpaca/broker/enums.py b/alpaca/broker/enums.py index f99f4955..6bc9074f 100644 --- a/alpaca/broker/enums.py +++ b/alpaca/broker/enums.py @@ -316,3 +316,26 @@ class UploadDocumentMimeType(str, Enum): PNG = "image/png" JPEG = "image/jpeg" JSON = "application/json" + + +class ACHRelationshipStatus(str, Enum): + """ + Represents the state that an ACHRelationship is in. + + Please see https://alpaca.markets/docs/api-references/broker-api/funding/ach/#attributes for more details + """ + + QUEUED = "QUEUED" + APPROVED = "APPROVED" + PENDING = "PENDING" + + +class BankAccountType(str, Enum): + """ + Represents a kind of bank account. + + Please see https://alpaca.markets/docs/api-references/broker-api/funding/ach/#attributes + """ + + CHECKING = "CHECKING" + SAVINGS = "SAVINGS" diff --git a/alpaca/broker/models/__init__.py b/alpaca/broker/models/__init__.py index c7266340..de674897 100644 --- a/alpaca/broker/models/__init__.py +++ b/alpaca/broker/models/__init__.py @@ -2,3 +2,4 @@ from .cip import * from .requests import * from .documents import * +from .funding import * diff --git a/alpaca/broker/models/funding.py b/alpaca/broker/models/funding.py new file mode 100644 index 00000000..577acbf4 --- /dev/null +++ b/alpaca/broker/models/funding.py @@ -0,0 +1,35 @@ +from datetime import datetime +from typing import Optional +from uuid import UUID + +from ..enums import ACHRelationshipStatus, BankAccountType +from alpaca.common.models import ValidateBaseModel as BaseModel + + +class ACHRelationship(BaseModel): + """ + Attributes: + id (UUID): ID of Relationship + account_id (UUID): ID of the Account this ACHRelationship is tied to + created_at (datetime): Date and time this relationship was created + updated_at (datetime): Date and time of when this relationship was last updated + status (ACHRelationshipStatus): Current status of the relationship + account_owner_name (str): Full name of the account owner + bank_account_type (BankAccountType): The kind of bank account this relationship points to + bank_account_number (str): The number of bank account that the relationship points to + bank_routing_number (str): Routing number for the bank account + nickname (str): User provided name for account + processor_token (Optional[str]): If you are using Plaid, then this is a Plaid processor token. + """ + + id: UUID + account_id: UUID + created_at: datetime + updated_at: datetime + status: ACHRelationshipStatus + account_owner_name: str + bank_account_type: BankAccountType + bank_account_number: str + bank_routing_number: str + nickname: str + processor_token: Optional[str] = None diff --git a/docs/api_reference/broker/models/funding.rst b/docs/api_reference/broker/models/funding.rst new file mode 100644 index 00000000..7eba8991 --- /dev/null +++ b/docs/api_reference/broker/models/funding.rst @@ -0,0 +1,19 @@ +.. toctree:: + :maxdepth: 2 + :caption: Contents: + +Models For Accessing and Controlling Funding of Accounts +======================================================== + +This page is for the models representing the information that various API requests require/can use. + +This has been separated out into a different module internally (and here in the docs) for ease of development +but is still accessible from ``alpaca.broker.models`` directly. + +For example: + +>>> from alpaca.broker.models import ACHRelationship + + +.. automodule:: alpaca.broker.models.funding + :members: diff --git a/tools/scripts/generate-docs.sh b/tools/scripts/generate-docs.sh index a3b675cb..5d48660f 100755 --- a/tools/scripts/generate-docs.sh +++ b/tools/scripts/generate-docs.sh @@ -12,4 +12,4 @@ poetry run make clean #run make html with a flag to make sphinx treat warnings as errors instead of generating incomplete docs #we also run doctest to ensure any doctests are successful before generating html -poetry run make doctest html SPHINXOPTS="-W" +poetry run make html doctest SPHINXOPTS="-W"