Skip to main content

Client for SnapTrade

Project description

Visit SnapTrade

SnapTrade

Connect brokerage accounts to your app for live positions and trading

PyPI README.md More Info

Table of Contents

Requirements

Python >=3.7

Installation

pip install snaptrade-python-sdk==11.0.29

Getting Started

import os
import uuid
from pprint import pprint
from snaptrade_client import SnapTrade

# 1) Initialize a client with your clientID and consumerKey.
snaptrade = SnapTrade(
    consumer_key=os.environ["SNAPTRADE_CONSUMER_KEY"],
    client_id=os.environ["SNAPTRADE_CLIENT_ID"],
)

# 2) Check that the client is able to make a request to the API server.
api_response = snaptrade.api_status.check()
pprint(api_response.body)

# 3) Create a new user on SnapTrade
user_id = str(uuid.uuid4())
register_response = snaptrade.authentication.register_snap_trade_user(
    body={"userId": user_id}
)
pprint(register_response.body)

# Note: A user secret is only generated once. It's required to access
# resources for certain endpoints.
user_secret = register_response.body["userSecret"]

# 4) Get a redirect URI. Users will need this to connect
# their brokerage to the SnapTrade server.
redirect_uri = snaptrade.authentication.login_snap_trade_user(
    query_params={"userId": user_id, "userSecret": user_secret}
)
print(redirect_uri.body)

# 5) Obtaining account holdings data
holdings = snaptrade.account_information.get_all_user_holdings(
    query_params={"userId": user_id, "userSecret": user_secret}
)
pprint(holdings.body)

# 6) Deleting a user
deleted_response = snaptrade.authentication.delete_snap_trade_user(
    query_params={"userId": user_id}
)
pprint(deleted_response.body)

Async

async support is available by prepending a to any method.

import asyncio
from pprint import pprint
from snaptrade_client import SnapTrade, ApiException

snaptrade = SnapTrade(
    consumer_key="YOUR_CONSUMER_KEY",
    client_id="YOUR_CLIENT_ID",
)


async def main():
    try:
        # List all accounts for the user, plus balances, positions, and orders for each account.
        get_all_user_holdings_response = (
            await snaptrade.account_information.aget_all_user_holdings(
                user_id="snaptrade-user-123",
                user_secret="USERSECRET123",
                brokerage_authorizations="917c8734-8470-4a3e-a18f-57c3f2ee6631",
            )
        )
        pprint(get_all_user_holdings_response.body)
        pprint(get_all_user_holdings_response.body["account"])
        pprint(get_all_user_holdings_response.body["balances"])
        pprint(get_all_user_holdings_response.body["positions"])
        pprint(get_all_user_holdings_response.body["total_value"])
        pprint(get_all_user_holdings_response.headers)
        pprint(get_all_user_holdings_response.status)
        pprint(get_all_user_holdings_response.round_trip_time)
    except ApiException as e:
        print(
            "Exception when calling AccountInformationApi.get_all_user_holdings: %s\n"
            % e
        )
        pprint(e.body)
        pprint(e.headers)
        pprint(e.status)
        pprint(e.reason)
        pprint(e.round_trip_time)


asyncio.run(main())

Reference

snaptrade.account_information.get_all_user_holdings

Deprecated

Deprecated, please use the account-specific holdings endpoint instead.

List all accounts for the user, plus balances, positions, and orders for each account.

๐Ÿ› ๏ธ Usage

get_all_user_holdings_response = snaptrade.account_information.get_all_user_holdings(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    brokerage_authorizations="917c8734-8470-4a3e-a18f-57c3f2ee6631",
)

โš™๏ธ Parameters

user_id: str
user_secret: str
brokerage_authorizations: str

Optional. Comma seperated list of authorization IDs (only use if filtering is needed on one or more authorizations).

๐Ÿ”„ Return

AccountHoldings

๐ŸŒ Endpoint

/holdings get

๐Ÿ”™ Back to Table of Contents


snaptrade.account_information.get_user_account_balance

A list of account balances for the specified account (one per currency that the account holds).

๐Ÿ› ๏ธ Usage

get_user_account_balance_response = (
    snaptrade.account_information.get_user_account_balance(
        user_id="snaptrade-user-123",
        user_secret="USERSECRET123",
        account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
    )
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str

The ID of the account to get balances.

๐Ÿ”„ Return

Balance

๐ŸŒ Endpoint

/accounts/{accountId}/balances get

๐Ÿ”™ Back to Table of Contents


snaptrade.account_information.get_user_account_details

Returns an account object with details for the specified account, including the total account market value.

๐Ÿ› ๏ธ Usage

get_user_account_details_response = (
    snaptrade.account_information.get_user_account_details(
        user_id="snaptrade-user-123",
        user_secret="USERSECRET123",
        account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
    )
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str

The ID of the account to get detail of.

๐Ÿ”„ Return

Account

๐ŸŒ Endpoint

/accounts/{accountId} get

๐Ÿ”™ Back to Table of Contents


snaptrade.account_information.get_user_account_orders

Fetch all recent orders from a user's account.

๐Ÿ› ๏ธ Usage

get_user_account_orders_response = (
    snaptrade.account_information.get_user_account_orders(
        user_id="snaptrade-user-123",
        user_secret="USERSECRET123",
        account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
        state="all",
        days=30,
    )
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str

The ID of the account to get orders.

state: str

defaults value is set to "all"

days: int

Number of days in the past to fetch the most recent orders. Defaults to the last 30 days if no value is passed in.

๐Ÿ”„ Return

AccountOrderRecord

๐ŸŒ Endpoint

/accounts/{accountId}/orders get

๐Ÿ”™ Back to Table of Contents


snaptrade.account_information.get_user_account_positions

Returns a list of positions in the specified account.

๐Ÿ› ๏ธ Usage

get_user_account_positions_response = (
    snaptrade.account_information.get_user_account_positions(
        user_id="snaptrade-user-123",
        user_secret="USERSECRET123",
        account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
    )
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str

The ID of the account to get positions.

๐Ÿ”„ Return

Position

๐ŸŒ Endpoint

/accounts/{accountId}/positions get

๐Ÿ”™ Back to Table of Contents


snaptrade.account_information.get_user_holdings

Lists balances, positions and orders for the specified account as well as option_positions and account metadata. The data returned is similar to the data returned over the more fine-grained positions, orders and balances endpoints.

๐Ÿ› ๏ธ Usage

get_user_holdings_response = snaptrade.account_information.get_user_holdings(
    account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
)

โš™๏ธ Parameters

account_id: str

The ID of the account to fetch holdings for.

user_id: str
user_secret: str

๐Ÿ”„ Return

AccountHoldingsAccount

๐ŸŒ Endpoint

/accounts/{accountId}/holdings get

๐Ÿ”™ Back to Table of Contents


snaptrade.account_information.list_user_accounts

Get a list of all Account objects for the authenticated SnapTrade user.

๐Ÿ› ๏ธ Usage

list_user_accounts_response = snaptrade.account_information.list_user_accounts(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
)

โš™๏ธ Parameters

user_id: str
user_secret: str

๐Ÿ”„ Return

Account

๐ŸŒ Endpoint

/accounts get

๐Ÿ”™ Back to Table of Contents


snaptrade.account_information.update_user_account

Updates various properties of a specified account.

๐Ÿ› ๏ธ Usage

update_user_account_response = snaptrade.account_information.update_user_account(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    account_id="accountId_example",
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str

The ID of the account to update.

๐Ÿ”„ Return

Account

๐ŸŒ Endpoint

/accounts/{accountId} put

๐Ÿ”™ Back to Table of Contents


snaptrade.api_status.check

Check whether the API is operational and verify timestamps.

๐Ÿ› ๏ธ Usage

check_response = snaptrade.api_status.check()

๐Ÿ”„ Return

Status

๐ŸŒ Endpoint

/ get

๐Ÿ”™ Back to Table of Contents


snaptrade.authentication.delete_snap_trade_user

Deletes a user you've registered over the SnapTrade API, and any data associated with them or their investment accounts.

๐Ÿ› ๏ธ Usage

delete_snap_trade_user_response = snaptrade.authentication.delete_snap_trade_user(
    user_id="snaptrade-user-123",
)

โš™๏ธ Parameters

user_id: str

๐Ÿ”„ Return

DeleteUserResponse

๐ŸŒ Endpoint

/snapTrade/deleteUser delete

๐Ÿ”™ Back to Table of Contents


snaptrade.authentication.list_snap_trade_users

Returns a list of users you've registered over the SnapTrade API.

๐Ÿ› ๏ธ Usage

list_snap_trade_users_response = snaptrade.authentication.list_snap_trade_users()

๐Ÿ”„ Return

UserList

๐ŸŒ Endpoint

/snapTrade/listUsers get

๐Ÿ”™ Back to Table of Contents


snaptrade.authentication.login_snap_trade_user

Logs in a SnapTrade user and returns an authenticated connection portal URL for them to use to connect a brokerage account.

๐Ÿ› ๏ธ Usage

login_snap_trade_user_response = snaptrade.authentication.login_snap_trade_user(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    broker="ALPACA",
    immediate_redirect=True,
    custom_redirect="https://snaptrade.com",
    reconnect="8b5f262d-4bb9-365d-888a-202bd3b15fa1",
    connection_type="read",
    connection_portal_version="v2",
)

โš™๏ธ Parameters

user_id: str
user_secret: str
broker: str

Slug of the brokerage to connect the user to. See this document for a list of supported brokerages and their slugs.

immediate_redirect: bool

When set to True, user will be redirected back to the partner's site instead of the connection portal

custom_redirect: str

URL to redirect the user to after the user connects their brokerage account

reconnect: str

The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See โ€˜Reconnecting Accountsโ€™ for more information.

connection_type: str

Sets whether the connection should be read or trade

connection_portal_version: str

Sets the version of the connection portal to render, with a default to 'v3'

โš™๏ธ Request Body

SnapTradeLoginUserRequestBody

๐ŸŒ Endpoint

/snapTrade/login post

๐Ÿ”™ Back to Table of Contents


snaptrade.authentication.register_snap_trade_user

Registers a new SnapTrade user under your ClientID. A user secret will be automatically generated for you and must be properly stored in your database. Most SnapTrade operations require a user ID and user secret to be passed as a parameter.

๐Ÿ› ๏ธ Usage

register_snap_trade_user_response = snaptrade.authentication.register_snap_trade_user(
    user_id="snaptrade-user-123",
)

โš™๏ธ Parameters

user_id: str

SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.

โš™๏ธ Request Body

SnapTradeRegisterUserRequestBody

๐Ÿ”„ Return

UserIDandSecret

๐ŸŒ Endpoint

/snapTrade/registerUser post

๐Ÿ”™ Back to Table of Contents


snaptrade.authentication.reset_snap_trade_user_secret

This API is used to rotate the secret for a SnapTrade user. You might use this if a userSecret is compromised. Please note that if you call this endpoint and fail to save the new secret, you'll no longer be able to access any data for this user, and your only option will be to delete and recreate the user, then ask them to reconnect.

๐Ÿ› ๏ธ Usage

reset_snap_trade_user_secret_response = (
    snaptrade.authentication.reset_snap_trade_user_secret(
        user_id="snaptrade-user-123",
        user_secret="h81@cx1lkalablakwjaltkejraj11=",
    )
)

โš™๏ธ Parameters

user_id: str

SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.

user_secret: str

SnapTrade User Secret randomly generated by SnapTrade. This is privileged information and if compromised, should be rotated via the SnapTrade API.

โš™๏ธ Request Body

UserIDandSecret

๐Ÿ”„ Return

UserIDandSecret

๐ŸŒ Endpoint

/snapTrade/resetUserSecret post

๐Ÿ”™ Back to Table of Contents


snaptrade.connections.detail_brokerage_authorization

Returns a single brokerage authorization object for the specified ID.

๐Ÿ› ๏ธ Usage

detail_brokerage_authorization_response = (
    snaptrade.connections.detail_brokerage_authorization(
        authorization_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
        user_id="snaptrade-user-123",
        user_secret="USERSECRET123",
    )
)

โš™๏ธ Parameters

authorization_id: str

The ID of a brokerage authorization object.

user_id: str
user_secret: str

๐Ÿ”„ Return

BrokerageAuthorization

๐ŸŒ Endpoint

/authorizations/{authorizationId} get

๐Ÿ”™ Back to Table of Contents


snaptrade.connections.disable_brokerage_authorization

Manually disable a connection. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a CONNECTION_BROKEN webhook for the connection. Please contact us in order to use this endpoint as it is disabled by default.

๐Ÿ› ๏ธ Usage

disable_brokerage_authorization_response = (
    snaptrade.connections.disable_brokerage_authorization(
        authorization_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
        user_id="snaptrade-user-123",
        user_secret="USERSECRET123",
    )
)

โš™๏ธ Parameters

authorization_id: str

The ID of a brokerage authorization object.

user_id: str
user_secret: str

๐Ÿ”„ Return

BrokerageAuthorizationDisabledConfirmation

๐ŸŒ Endpoint

/authorizations/{authorizationId}/disable post

๐Ÿ”™ Back to Table of Contents


snaptrade.connections.list_brokerage_authorizations

Returns a list of Brokerage Authorization objects for the user

๐Ÿ› ๏ธ Usage

list_brokerage_authorizations_response = (
    snaptrade.connections.list_brokerage_authorizations(
        user_id="snaptrade-user-123",
        user_secret="USERSECRET123",
    )
)

โš™๏ธ Parameters

user_id: str
user_secret: str

๐Ÿ”„ Return

BrokerageAuthorization

๐ŸŒ Endpoint

/authorizations get

๐Ÿ”™ Back to Table of Contents


snaptrade.connections.refresh_brokerage_authorization

Trigger a holdings update for all accounts under this authorization. Updates will be queued asynchronously. ACCOUNT_HOLDINGS_UPDATED webhook will be sent once the sync completes. Please contact support for access as this endpoint is not enabled by default

๐Ÿ› ๏ธ Usage

refresh_brokerage_authorization_response = (
    snaptrade.connections.refresh_brokerage_authorization(
        authorization_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
        user_id="snaptrade-user-123",
        user_secret="USERSECRET123",
    )
)

โš™๏ธ Parameters

authorization_id: str

The ID of a brokerage authorization object.

user_id: str
user_secret: str

๐Ÿ”„ Return

BrokerageAuthorizationRefreshConfirmation

๐ŸŒ Endpoint

/authorizations/{authorizationId}/refresh post

๐Ÿ”™ Back to Table of Contents


snaptrade.connections.remove_brokerage_authorization

Deletes a specified brokerage authorization given by the ID.

๐Ÿ› ๏ธ Usage

snaptrade.connections.remove_brokerage_authorization(
    authorization_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
)

โš™๏ธ Parameters

authorization_id: str

The ID of the Authorization to delete.

user_id: str
user_secret: str

๐ŸŒ Endpoint

/authorizations/{authorizationId} delete

๐Ÿ”™ Back to Table of Contents


snaptrade.connections.session_events

Returns a list of session events associated with a user.

๐Ÿ› ๏ธ Usage

session_events_response = snaptrade.connections.session_events(
    partner_client_id="SNAPTRADETEST",
    user_id="917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
    session_id="917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
)

โš™๏ธ Parameters

partner_client_id: str
user_id: str

Optional comma seperated list of user IDs used to filter the request on specific users

session_id: str

Optional comma seperated list of session IDs used to filter the request on specific users

๐ŸŒ Endpoint

/sessionEvents get

๐Ÿ”™ Back to Table of Contents


snaptrade.options.get_option_strategy

Creates an option strategy object that will be used to place an option strategy order.

๐Ÿ› ๏ธ Usage

get_option_strategy_response = snaptrade.options.get_option_strategy(
    underlying_symbol_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
    legs=[
        {
            "action": "BUY_TO_OPEN",
            "option_symbol_id": "SPY220819P00200000",
            "quantity": 1,
        }
    ],
    strategy_type="CUSTOM",
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    account_id="accountId_example",
)

โš™๏ธ Parameters

underlying_symbol_id: str
legs: List[OptionLeg]
strategy_type: str
user_id: str
user_secret: str
account_id: str

The ID of the account to create the option strategy object in.

โš™๏ธ Request Body

Any

๐Ÿ”„ Return

StrategyQuotes

๐ŸŒ Endpoint

/accounts/{accountId}/optionStrategy post

๐Ÿ”™ Back to Table of Contents


snaptrade.options.get_options_chain

Returns the option chain for the specified symbol in the specified account.

๐Ÿ› ๏ธ Usage

get_options_chain_response = snaptrade.options.get_options_chain(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    account_id="accountId_example",
    symbol="symbol_example",
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str

The ID of the account to get the options chain from.

symbol: str

Universal symbol ID if symbol

๐Ÿ”„ Return

OptionChain

๐ŸŒ Endpoint

/accounts/{accountId}/optionsChain get

๐Ÿ”™ Back to Table of Contents


snaptrade.options.get_options_strategy_quote

Returns a Strategy Quotes object which has latest market data of the specified option strategy.

๐Ÿ› ๏ธ Usage

get_options_strategy_quote_response = snaptrade.options.get_options_strategy_quote(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    account_id="accountId_example",
    option_strategy_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str

The ID of the account the strategy will be placed in.

option_strategy_id: str

Option strategy id obtained from response when creating option strategy object

๐Ÿ”„ Return

StrategyQuotes

๐ŸŒ Endpoint

/accounts/{accountId}/optionStrategy/{optionStrategyId} get

๐Ÿ”™ Back to Table of Contents


snaptrade.options.list_option_holdings

Returns a list of Options Positions.

๐Ÿ› ๏ธ Usage

list_option_holdings_response = snaptrade.options.list_option_holdings(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    account_id="accountId_example",
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str

The ID of the account to fetch options holdings for.

๐Ÿ”„ Return

OptionsPosition

๐ŸŒ Endpoint

/accounts/{accountId}/options get

๐Ÿ”™ Back to Table of Contents


snaptrade.options.place_option_strategy

Places the option strategy order and returns the order record received from the brokerage.

๐Ÿ› ๏ธ Usage

place_option_strategy_response = snaptrade.options.place_option_strategy(
    order_type="Limit",
    time_in_force="FOK",
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    account_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
    option_strategy_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
    price=31.33,
)

โš™๏ธ Parameters

order_type: OrderTypeStrict
time_in_force: TimeInForceStrict
user_id: str
user_secret: str
account_id: str

The ID of the account to execute the strategy in.

option_strategy_id: str

Option strategy id obtained from response when creating option strategy object

price: Price

โš™๏ธ Request Body

Any

๐Ÿ”„ Return

StrategyOrderRecord

๐ŸŒ Endpoint

/accounts/{accountId}/optionStrategy/{optionStrategyId}/execute post

๐Ÿ”™ Back to Table of Contents


snaptrade.reference_data.get_currency_exchange_rate_pair

Returns an Exchange Rate Pair object for the specified Currency Pair.

๐Ÿ› ๏ธ Usage

get_currency_exchange_rate_pair_response = (
    snaptrade.reference_data.get_currency_exchange_rate_pair(
        currency_pair="currencyPair_example",
    )
)

โš™๏ธ Parameters

currency_pair: str

A currency pair based on currency code for example, {CAD-USD}

๐Ÿ”„ Return

ExchangeRatePairs

๐ŸŒ Endpoint

/currencies/rates/{currencyPair} get

๐Ÿ”™ Back to Table of Contents


snaptrade.reference_data.get_partner_info

Returns useful data related to the specified ClientID, including allowed brokerages and data access.

๐Ÿ› ๏ธ Usage

get_partner_info_response = snaptrade.reference_data.get_partner_info()

๐Ÿ”„ Return

PartnerData

๐ŸŒ Endpoint

/snapTrade/partners get

๐Ÿ”™ Back to Table of Contents


snaptrade.reference_data.get_security_types

List security types available on SnapTrade.

๐Ÿ› ๏ธ Usage

get_security_types_response = snaptrade.reference_data.get_security_types()

๐Ÿ”„ Return

SecurityType

๐ŸŒ Endpoint

/securityTypes get

๐Ÿ”™ Back to Table of Contents


snaptrade.reference_data.get_stock_exchanges

Returns a list of all supported Exchanges.

๐Ÿ› ๏ธ Usage

get_stock_exchanges_response = snaptrade.reference_data.get_stock_exchanges()

๐Ÿ”„ Return

Exchange

๐ŸŒ Endpoint

/exchanges get

๐Ÿ”™ Back to Table of Contents


snaptrade.reference_data.get_symbols

Returns a list of Universal Symbol objects that match a defined string.

Matches on ticker or name.

๐Ÿ› ๏ธ Usage

get_symbols_response = snaptrade.reference_data.get_symbols(
    substring="apple",
)

โš™๏ธ Parameters

substring: str

โš™๏ธ Request Body

SymbolQuery

๐Ÿ”„ Return

UniversalSymbol

๐ŸŒ Endpoint

/symbols post

๐Ÿ”™ Back to Table of Contents


snaptrade.reference_data.get_symbols_by_ticker

Returns the Universal Symbol object specified by the ticker or the universal_symbol_id.

๐Ÿ› ๏ธ Usage

get_symbols_by_ticker_response = snaptrade.reference_data.get_symbols_by_ticker(
    query="query_example",
)

โš™๏ธ Parameters

query: str

The ticker or universal_symbol_id of the UniversalSymbol to get.

๐Ÿ”„ Return

UniversalSymbol

๐ŸŒ Endpoint

/symbols/{query} get

๐Ÿ”™ Back to Table of Contents


snaptrade.reference_data.list_all_brokerage_authorization_type

Returns a list of all defined Brokerage authorization Type objects.

๐Ÿ› ๏ธ Usage

list_all_brokerage_authorization_type_response = (
    snaptrade.reference_data.list_all_brokerage_authorization_type(
        brokerage="QUESTRADE,ALPACA",
    )
)

โš™๏ธ Parameters

brokerage: str

Comma separated value of brokerage slugs

๐Ÿ”„ Return

BrokerageAuthorizationTypeReadOnly

๐ŸŒ Endpoint

/brokerageAuthorizationTypes get

๐Ÿ”™ Back to Table of Contents


snaptrade.reference_data.list_all_brokerages

Returns a list of all defined Brokerage objects.

๐Ÿ› ๏ธ Usage

list_all_brokerages_response = snaptrade.reference_data.list_all_brokerages()

๐Ÿ”„ Return

Brokerage

๐ŸŒ Endpoint

/brokerages get

๐Ÿ”™ Back to Table of Contents


snaptrade.reference_data.list_all_currencies

Returns a list of all defined Currency objects.

๐Ÿ› ๏ธ Usage

list_all_currencies_response = snaptrade.reference_data.list_all_currencies()

๐Ÿ”„ Return

Currency

๐ŸŒ Endpoint

/currencies get

๐Ÿ”™ Back to Table of Contents


snaptrade.reference_data.list_all_currencies_rates

Returns a list of all Exchange Rate Pairs for all supported Currencies.

๐Ÿ› ๏ธ Usage

list_all_currencies_rates_response = (
    snaptrade.reference_data.list_all_currencies_rates()
)

๐Ÿ”„ Return

ExchangeRatePairs

๐ŸŒ Endpoint

/currencies/rates get

๐Ÿ”™ Back to Table of Contents


snaptrade.reference_data.symbol_search_user_account

Returns a list of universal symbols that are supported by the specificied account. Returned symbols are based on the provided search string, matching on ticker and name.

๐Ÿ› ๏ธ Usage

symbol_search_user_account_response = (
    snaptrade.reference_data.symbol_search_user_account(
        user_id="snaptrade-user-123",
        user_secret="USERSECRET123",
        account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
        substring="apple",
    )
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str

The ID of the account to search for symbols within.

substring: str

โš™๏ธ Request Body

SymbolQuery

๐Ÿ”„ Return

UniversalSymbol

๐ŸŒ Endpoint

/accounts/{accountId}/symbols post

๐Ÿ”™ Back to Table of Contents


snaptrade.trading.cancel_user_account_order

Sends a signal to the brokerage to cancel the specified order. This will only work if the order has not yet been executed.

๐Ÿ› ๏ธ Usage

cancel_user_account_order_response = snaptrade.trading.cancel_user_account_order(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
    brokerage_order_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str

The ID of the account to cancel the order in.

brokerage_order_id: str

โš™๏ธ Request Body

Any The Order ID to be canceled

๐Ÿ”„ Return

AccountOrderRecord

๐ŸŒ Endpoint

/accounts/{accountId}/orders/cancel post

๐Ÿ”™ Back to Table of Contents


snaptrade.trading.get_order_impact

Return the trade object and it's impact on the account for the specified order.

๐Ÿ› ๏ธ Usage

get_order_impact_response = snaptrade.trading.get_order_impact(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    account_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
    action="BUY",
    order_type="Limit",
    price=31.33,
    stop=31.33,
    time_in_force="FOK",
    units=3.14,
    universal_symbol_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
    notional_value=None,
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str
action: ActionStrict
order_type: OrderTypeStrict
price: Price
stop: StopPrice
time_in_force: TimeInForceStrict
units: UnitsNullable
universal_symbol_id: str
notional_value: NotionalValueNullable

โš™๏ธ Request Body

ManualTradeForm

๐Ÿ”„ Return

ManualTradeAndImpact

๐ŸŒ Endpoint

/trade/impact post

๐Ÿ”™ Back to Table of Contents


snaptrade.trading.get_user_account_quotes

Returns quote(s) from the brokerage for the specified symbol(s).

๐Ÿ› ๏ธ Usage

get_user_account_quotes_response = snaptrade.trading.get_user_account_quotes(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    symbols="symbols_example",
    account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
    use_ticker=True,
)

โš™๏ธ Parameters

user_id: str
user_secret: str
symbols: str

List of universal_symbol_id or tickers to get quotes for.

account_id: str

The ID of the account to get quotes.

use_ticker: bool

Should be set to True if providing tickers.

๐Ÿ”„ Return

SymbolsQuotes

๐ŸŒ Endpoint

/accounts/{accountId}/quotes get

๐Ÿ”™ Back to Table of Contents


snaptrade.trading.place_force_order

Places a specified trade in the specified account.

๐Ÿ› ๏ธ Usage

place_force_order_response = snaptrade.trading.place_force_order(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    account_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
    action="BUY",
    order_type="Limit",
    price=31.33,
    stop=31.33,
    time_in_force="FOK",
    units=3.14,
    universal_symbol_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
    notional_value=None,
)

โš™๏ธ Parameters

user_id: str
user_secret: str
account_id: str
action: ActionStrict
order_type: OrderTypeStrict
price: Price
stop: StopPrice
time_in_force: TimeInForceStrict
units: UnitsNullable
universal_symbol_id: str
notional_value: NotionalValueNullable

โš™๏ธ Request Body

ManualTradeForm

๐Ÿ”„ Return

AccountOrderRecord

๐ŸŒ Endpoint

/trade/place post

๐Ÿ”™ Back to Table of Contents


snaptrade.trading.place_order

Places the specified trade object. This places the order in the account and returns the status of the order from the brokerage.

๐Ÿ› ๏ธ Usage

place_order_response = snaptrade.trading.place_order(
    trade_id="tradeId_example",
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    wait_to_confirm=True,
)

โš™๏ธ Parameters

trade_id: str

The ID of trade object obtained from trade/impact endpoint

user_id: str
user_secret: str
wait_to_confirm: Optional[bool]

Optional, defaults to true. Determines if a wait is performed to check on order status. If false, latency will be reduced but orders returned will be more likely to be of status PENDING as we will not wait to check on the status before responding to the request

โš™๏ธ Request Body

ValidatedTradeBody

๐Ÿ”„ Return

AccountOrderRecord

๐ŸŒ Endpoint

/trade/{tradeId} post

๐Ÿ”™ Back to Table of Contents


snaptrade.transactions_and_reporting.get_activities

Returns activities (transactions) for a user. Specifying start and end date is highly recommended for better performance

๐Ÿ› ๏ธ Usage

get_activities_response = snaptrade.transactions_and_reporting.get_activities(
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    start_date="2022-01-24",
    end_date="2022-01-24",
    accounts="917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
    brokerage_authorizations="917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
    type="DIVIDEND",
)

โš™๏ธ Parameters

user_id: str
user_secret: str
start_date: date
end_date: date
accounts: str

Optional comma seperated list of account IDs used to filter the request on specific accounts

brokerage_authorizations: str

Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations

type: str

Optional comma seperated list of types to filter activities by. This is not an exhaustive list, if we fail to match to these types, we will return the raw description from the brokerage. Potential values include - DIVIDEND - BUY - SELL - CONTRIBUTION - WITHDRAWAL - EXTERNAL_ASSET_TRANSFER_IN - EXTERNAL_ASSET_TRANSFER_OUT - INTERNAL_CASH_TRANSFER_IN - INTERNAL_CASH_TRANSFER_OUT - INTERNAL_ASSET_TRANSFER_IN - INTERNAL_ASSET_TRANSFER_OUT - INTEREST - REBATE - GOV_GRANT - TAX - FEE - REI - FXT

๐Ÿ”„ Return

UniversalActivity

๐ŸŒ Endpoint

/activities get

๐Ÿ”™ Back to Table of Contents


snaptrade.transactions_and_reporting.get_reporting_custom_range

Deprecated

Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Please note that Total Equity Timeframe and Rate of Returns are experimental features. Please contact support@snaptrade.com if you notice any inconsistencies.

๐Ÿ› ๏ธ Usage

get_reporting_custom_range_response = snaptrade.transactions_and_reporting.get_reporting_custom_range(
    start_date="2022-01-24",
    end_date="2022-01-24",
    user_id="snaptrade-user-123",
    user_secret="USERSECRET123",
    accounts="917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
    detailed=True,
    frequency="monthly",
)

โš™๏ธ Parameters

start_date: date
end_date: date
user_id: str
user_secret: str
accounts: str

Optional comma seperated list of account IDs used to filter the request on specific accounts

detailed: bool

Optional, increases frequency of data points for the total value and contribution charts if set to true

frequency: str

Optional frequency for the rate of return chart (defaults to monthly). Possible values are daily, weekly, monthly, quarterly, yearly.

๐Ÿ”„ Return

PerformanceCustom

๐ŸŒ Endpoint

/performance/custom get

๐Ÿ”™ Back to Table of Contents


Author

This Python package is automatically generated by Konfig

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snaptrade_python_sdk-11.0.29.tar.gz (209.6 kB view hashes)

Uploaded Source

Built Distribution

snaptrade_python_sdk-11.0.29-py3-none-any.whl (848.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page