Accounts#

The accounts API allows you to create brokerage accounts on behalf of your users. It also lets you manage accounts under your custody.

Create an Account#

BrokerClient.create_account(account_data: CreateAccountRequest) Account#

Create an account.

Parameters

account_data (CreateAccountRequest) – The data representing the Account you wish to create

Returns

The newly created Account instance as returned from the API. Should now have id and other generated fields filled out.

Return type

Account

Get Account By ID#

BrokerClient.get_account_by_id(account_id: Union[UUID, str]) Account#

Get an Account by its associated account_id.

Note: If no account is found the api returns a 401, not a 404

Parameters
  • account_id (Union[UUID, str]) – The id of the account you wish to get. str uuid values will be upcast

  • instances (into UUID) –

Returns

Returns the requested account.

Return type

Account

Update Account#

BrokerClient.update_account(account_id: Union[UUID, str], update_data: UpdateAccountRequest) Account#

Updates data for an account with an id of account_id. Note that not all data for an account is modifiable after creation so there is a special data type of AccountUpdateRequest representing the data that is allowed to be modified.

see: https://alpaca.markets/docs/api-references/broker-api/accounts/accounts/#updating-an-account for more info

Parameters
  • account_id (Union[UUID, str]) – The id for the account you with to update. str uuid values will be upcast

  • instances (into UUID) –

  • update_data (UpdateAccountRequest) – The data you wish to update this account to

Returns

Returns an Account instance with the updated data as returned from the api

Return type

Account

Upload Documents to Account#

BrokerClient.upload_documents_to_account(account_id: Union[UUID, str], document_data: List[UploadDocumentRequest]) None#

Allows you to upload up to 10 documents at a time for an Account.

Document data must be a binary objects whose contents are encoded in base64. Each encoded content size is limited to 10MB if you use Alpaca for KYCaaS.

If you perform your own KYC there are no document size limitations.

Parameters
  • account_id (Union[UUID, str]) – The id of the Account you wish to upload the document data to.

  • document_data (List[UploadDocumentRequest]) – List of UploadDocumentRequest’s that contain the relevant Document data

Returns

This function returns nothing on success and will raise an APIError in case of a failure

Return type

None

Raises

APIError – this will be raised if the API didn’t return a 204 for your request.

Delete Account#

BrokerClient.delete_account(account_id: Union[UUID, str]) None#

Delete an Account by its id.

As the api itself returns a 204 on success this function returns nothing in the successful case and will raise and exception in any other case.

Parameters
  • account_id (Union[UUID, str]) – the id of the Account you wish to delete. str values will attempt to be

  • validate. (upcast to UUID to) –

Return type

None

List All Accounts#

BrokerClient.list_accounts(search_parameters: Optional[ListAccountsRequest] = None) List[Account]#

Get a List of Accounts allowing for passing in some filters.

Parameters

search_parameters (Optional[ListAccountsRequest]) – The various filtering criteria you can specify.

Returns

The filtered list of Accounts

Return type

List[Account]

Get Trade Account By ID#

BrokerClient.get_trade_account_by_id(account_id: Union[UUID, str]) TradeAccount#

Gets TradeAccount information for a given Account id.

Parameters

account_id (Union[UUID, str]) – The UUID identifier for the Account you wish to get the info for. str values will be upcast into UUID instances and checked for validity.

Returns

TradeAccount info for the given account if found.

Return type

alpaca.broker.models.accounts.TradeAccount

Get Trade Configuration For Account#

BrokerClient.get_trade_configuration_for_account(account_id: Union[UUID, str]) TradeAccountConfiguration#

Gets the TradeAccountConfiguration for a given Account.

Parameters

account_id (Union[UUID, str]) – The id of the Account you wish to get the TradeAccountConfiguration for

Returns

The resulting TradeAccountConfiguration for the Account

Return type

TradeAccountConfiguration

Update Trade Configuration For Account#

BrokerClient.update_trade_configuration_for_account(account_id: Union[UUID, str], config: TradeAccountConfiguration) TradeAccountConfiguration#

Updates an Account with new TradeAccountConfiguration information.

Parameters
  • account_id (Union[UUID, str]) – The id of the Account you wish to update.

  • config (UpdateTradeConfigurationRequest) – The Updated Options you wish to set on the Account

Returns

The resulting TradeAccountConfiguration with updates.

Return type

TradeAccountConfiguration