Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
snaptrade-python-sdk
Advanced tools
snaptrade.account_information.get_all_user_holdings
snaptrade.account_information.get_user_account_balance
snaptrade.account_information.get_user_account_details
snaptrade.account_information.get_user_account_orders
snaptrade.account_information.get_user_account_positions
snaptrade.account_information.get_user_account_recent_orders
snaptrade.account_information.get_user_account_return_rates
snaptrade.account_information.get_user_holdings
snaptrade.account_information.list_user_accounts
snaptrade.account_information.update_user_account
snaptrade.api_status.check
snaptrade.authentication.delete_snap_trade_user
snaptrade.authentication.list_snap_trade_users
snaptrade.authentication.login_snap_trade_user
snaptrade.authentication.register_snap_trade_user
snaptrade.authentication.reset_snap_trade_user_secret
snaptrade.connections.detail_brokerage_authorization
snaptrade.connections.disable_brokerage_authorization
snaptrade.connections.list_brokerage_authorizations
snaptrade.connections.refresh_brokerage_authorization
snaptrade.connections.remove_brokerage_authorization
snaptrade.connections.return_rates
snaptrade.connections.session_events
snaptrade.options.get_option_strategy
snaptrade.options.get_options_chain
snaptrade.options.get_options_strategy_quote
snaptrade.options.list_option_holdings
snaptrade.options.place_option_strategy
snaptrade.reference_data.get_currency_exchange_rate_pair
snaptrade.reference_data.get_partner_info
snaptrade.reference_data.get_security_types
snaptrade.reference_data.get_stock_exchanges
snaptrade.reference_data.get_symbols
snaptrade.reference_data.get_symbols_by_ticker
snaptrade.reference_data.list_all_brokerage_authorization_type
snaptrade.reference_data.list_all_brokerages
snaptrade.reference_data.list_all_currencies
snaptrade.reference_data.list_all_currencies_rates
snaptrade.reference_data.symbol_search_user_account
snaptrade.trading.cancel_user_account_order
snaptrade.trading.get_order_impact
snaptrade.trading.get_user_account_quotes
snaptrade.trading.place_force_order
snaptrade.trading.place_order
snaptrade.transactions_and_reporting.get_activities
snaptrade.transactions_and_reporting.get_reporting_custom_range
Python >=3.7
pip install snaptrade-python-sdk==11.0.58
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
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="adf2aa34-8219-40f7-a6b3-60156985cc61",
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())
snaptrade.account_information.get_all_user_holdings
Deprecated, please use the account-specific holdings endpoint instead.
List all accounts for the user, plus balances, positions, and orders for each account.
get_all_user_holdings_response = snaptrade.account_information.get_all_user_holdings(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
brokerage_authorizations="917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
str
str
str
Optional. Comma separated list of authorization IDs (only use if filtering is needed on one or more authorizations).
/holdings
get
snaptrade.account_information.get_user_account_balance
Returns a list of balances for the account. Each element of the list has a distinct currency. Some brokerages like Questrade allows holding multiple currencies in the same account.
The data returned here is cached. How long the data is cached for varies by brokerage. Check the brokerage integrations doc and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time data, please use the manual refresh endpoint.
get_user_account_balance_response = (
snaptrade.account_information.get_user_account_balance(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
)
str
str
str
/accounts/{accountId}/balances
get
snaptrade.account_information.get_user_account_details
Returns account detail known to SnapTrade for the specified account.
The data returned here is always cached and refreshed once a day. If you need real-time data, please use the manual refresh endpoint.
get_user_account_details_response = (
snaptrade.account_information.get_user_account_details(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
)
str
str
str
/accounts/{accountId}
get
snaptrade.account_information.get_user_account_orders
Returns a list of recent orders in the specified account.
The data returned here is cached. How long the data is cached for varies by brokerage. Check the brokerage integrations doc and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time data, please use the manual refresh endpoint.
get_user_account_orders_response = (
snaptrade.account_information.get_user_account_orders(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
state="all",
days=30,
)
)
str
str
str
str
defaults value is set to "all"
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.
/accounts/{accountId}/orders
get
snaptrade.account_information.get_user_account_positions
Returns a list of stock/ETF/crypto/mutual fund positions in the specified account. For option positions, please use the options endpoint.
The data returned here is cached. How long the data is cached for varies by brokerage. Check the brokerage integrations doc and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time data, please use the manual refresh endpoint.
get_user_account_positions_response = (
snaptrade.account_information.get_user_account_positions(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
)
str
str
str
/accounts/{accountId}/positions
get
snaptrade.account_information.get_user_account_recent_orders
Returns a list of orders executed in the last 24 hours in the specified account. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution Differs from /orders in that it only returns orders that have been executed in the last 24 hours as opposed to pending or cancelled orders up to 30 days old Please contact support for access as this endpoint is not enabled by default.
get_user_account_recent_orders_response = (
snaptrade.account_information.get_user_account_recent_orders(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
only_executed=True,
)
)
str
str
str
bool
Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well
/accounts/{accountId}/recentOrders
get
snaptrade.account_information.get_user_account_return_rates
Returns a list of rate of return percents for a given account. Will include timeframes available from the brokerage, for example "ALL", "1Y", "6M", "3M", "1M"
get_user_account_return_rates_response = (
snaptrade.account_information.get_user_account_return_rates(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
)
str
str
str
/accounts/{accountId}/returnRates
get
snaptrade.account_information.get_user_holdings
Returns a list of balances, positions, and recent orders for the specified account. The data returned is similar to the data returned over the more fine-grained balances, positions and orders endpoints. The finer-grained APIs are preferred. They are easier to work with, faster, and have better error handling than this coarse-grained API.
The data returned here is cached. How long the data is cached for varies by brokerage. Check the brokerage integrations doc and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time data, please use the manual refresh endpoint.
get_user_holdings_response = snaptrade.account_information.get_user_holdings(
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
)
str
str
str
/accounts/{accountId}/holdings
get
snaptrade.account_information.list_user_accounts
Returns all brokerage accounts across all connections known to SnapTrade for the authenticated user.
The data returned here is always cached and refreshed once a day. If you need real-time data, please use the manual refresh endpoint.
list_user_accounts_response = snaptrade.account_information.list_user_accounts(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
)
str
str
/accounts
get
snaptrade.account_information.update_user_account
Updates various properties of a specified account.
update_user_account_response = snaptrade.account_information.update_user_account(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="accountId_example",
)
str
str
str
The ID of the account to update.
/accounts/{accountId}
put
snaptrade.api_status.check
Check whether the API is operational and verify timestamps.
check_response = snaptrade.api_status.check()
/
get
snaptrade.authentication.delete_snap_trade_user
Deletes a registered user and all associated data. This action is irreversible. This API is asynchronous and will return a 200 status code if the request is accepted. The user and all associated data will be queued for deletion. Once deleted, a USER_DELETED
webhook will be sent.
delete_snap_trade_user_response = snaptrade.authentication.delete_snap_trade_user(
user_id="snaptrade-user-123",
)
str
/snapTrade/deleteUser
delete
snaptrade.authentication.list_snap_trade_users
Returns a list of all registered user IDs. Please note that the response is not currently paginated.
list_snap_trade_users_response = snaptrade.authentication.list_snap_trade_users()
/snapTrade/listUsers
get
snaptrade.authentication.login_snap_trade_user
Authenticates a SnapTrade user and returns the Connection Portal URL used for connecting brokerage accounts. Please check this guide for how to integrate the Connection Portal into your app.
Please note that the returned URL expires in 5 minutes.
login_snap_trade_user_response = snaptrade.authentication.login_snap_trade_user(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
broker="ALPACA",
immediate_redirect=True,
custom_redirect="https://snaptrade.com",
reconnect="8b5f262d-4bb9-365d-888a-202bd3b15fa1",
connection_type="read",
connection_portal_version="v4",
)
str
str
str
Slug of the brokerage to connect the user to. See the integrations page for a list of supported brokerages and their slugs.
bool
When set to true
, user will be redirected back to the partner's site instead of the connection portal. This parameter is ignored if the connection portal is loaded inside an iframe. See the guide on ways to integrate the connection portal for more information.
str
URL to redirect the user to after the user connects their brokerage account. This parameter is ignored if the connection portal is loaded inside an iframe. See the guide on ways to integrate the connection portal for more information.
str
The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See the guide on fixing broken connections for more information.
str
Sets whether the connection should be read-only or trade-enabled. Defaults to read-only if not specified.
str
Sets the connection portal version to render. Currently only v4 is supported and is the default. All other versions are deprecated and will automatically be set to v4.
/snapTrade/login
post
snaptrade.authentication.register_snap_trade_user
Registers a new SnapTrade user under your Client ID. A user secret will be automatically generated for you and must be properly stored in your system. Most SnapTrade operations require a user ID and user secret to be passed in as parameters.
register_snap_trade_user_response = snaptrade.authentication.register_snap_trade_user(
user_id="snaptrade-user-123",
)
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.
SnapTradeRegisterUserRequestBody
/snapTrade/registerUser
post
snaptrade.authentication.reset_snap_trade_user_secret
Rotates the secret for a SnapTrade user. You might use this if 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.
reset_snap_trade_user_secret_response = (
snaptrade.authentication.reset_snap_trade_user_secret(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
)
)
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.
str
SnapTrade User Secret. This is a randomly generated string and should be stored securely. If compromised, please rotate it via the rotate user secret endpoint.
/snapTrade/resetUserSecret
post
snaptrade.connections.detail_brokerage_authorization
Returns a single connection for the specified ID.
detail_brokerage_authorization_response = (
snaptrade.connections.detail_brokerage_authorization(
authorization_id="87b24961-b51e-4db8-9226-f198f6518a89",
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
)
)
str
str
str
/authorizations/{authorizationId}
get
snaptrade.connections.disable_brokerage_authorization
Manually force the specified connection to become disabled. 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.
disable_brokerage_authorization_response = (
snaptrade.connections.disable_brokerage_authorization(
authorization_id="87b24961-b51e-4db8-9226-f198f6518a89",
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
)
)
str
str
str
BrokerageAuthorizationDisabledConfirmation
/authorizations/{authorizationId}/disable
post
snaptrade.connections.list_brokerage_authorizations
Returns a list of all connections for the specified user. Note that Connection
and Brokerage Authorization
are interchangeable, but the term Connection
is preferred and used in the doc for consistency.
A connection is usually tied to a single login at a brokerage. A single connection can contain multiple brokerage accounts.
SnapTrade performs de-duping on connections for a given user. If the user has an existing connection with the brokerage, when connecting the brokerage with the same credentials, SnapTrade will return the existing connection instead of creating a new one.
list_brokerage_authorizations_response = (
snaptrade.connections.list_brokerage_authorizations(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
)
)
str
str
/authorizations
get
snaptrade.connections.refresh_brokerage_authorization
Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. ACCOUNT_HOLDINGS_UPDATED
webhook will be sent once the sync completes for each account under the connection.
Please contact support for access as this endpoint is not enabled by default.
refresh_brokerage_authorization_response = (
snaptrade.connections.refresh_brokerage_authorization(
authorization_id="87b24961-b51e-4db8-9226-f198f6518a89",
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
)
)
str
str
str
BrokerageAuthorizationRefreshConfirmation
/authorizations/{authorizationId}/refresh
post
snaptrade.connections.remove_brokerage_authorization
Deletes the connection specified by the ID. This will also delete all accounts and holdings associated with the connection. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the connection has been successfully deleted.
snaptrade.connections.remove_brokerage_authorization(
authorization_id="87b24961-b51e-4db8-9226-f198f6518a89",
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
)
str
str
str
/authorizations/{authorizationId}
delete
snaptrade.connections.return_rates
Returns a list of rate of return percents for a given connection. Will include timeframes available from the brokerage, for example "ALL", "1Y", "6M", "3M", "1M"
return_rates_response = snaptrade.connections.return_rates(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
authorization_id="87b24961-b51e-4db8-9226-f198f6518a89",
)
str
str
str
/authorizations/{authorizationId}/returnRates
get
snaptrade.connections.session_events
Returns a list of session events associated with a user.
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",
)
str
str
Optional comma separated list of user IDs used to filter the request on specific users
str
Optional comma separated list of session IDs used to filter the request on specific users
/sessionEvents
get
snaptrade.options.get_option_strategy
Creates an option strategy object that will be used to place an option strategy order.
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="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="accountId_example",
)
str
OptionLeg
]str
str
str
str
The ID of the account to create the option strategy object in.
/accounts/{accountId}/optionStrategy
post
snaptrade.options.get_options_chain
Returns the option chain for the specified symbol in the specified account.
get_options_chain_response = snaptrade.options.get_options_chain(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="accountId_example",
symbol="symbol_example",
)
str
str
str
The ID of the account to get the options chain from.
str
Universal symbol ID if symbol
/accounts/{accountId}/optionsChain
get
snaptrade.options.get_options_strategy_quote
Returns a Strategy Quotes object which has latest market data of the specified option strategy.
get_options_strategy_quote_response = snaptrade.options.get_options_strategy_quote(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="accountId_example",
option_strategy_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
)
str
str
str
The ID of the account the strategy will be placed in.
str
Option strategy id obtained from response when creating option strategy object
/accounts/{accountId}/optionStrategy/{optionStrategyId}
get
snaptrade.options.list_option_holdings
Returns a list of option positions in the specified account. For stock/ETF/crypto/mutual fund positions, please use the positions endpoint.
The data returned here is cached. How long the data is cached for varies by brokerage. Check the brokerage integrations doc and look for "Cache Expiry Time" to see the exact value for a specific brokerage. If you need real-time data, please use the manual refresh endpoint.
list_option_holdings_response = snaptrade.options.list_option_holdings(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
)
str
str
str
/accounts/{accountId}/options
get
snaptrade.options.place_option_strategy
Places the option strategy order and returns the order record received from the brokerage.
place_option_strategy_response = snaptrade.options.place_option_strategy(
order_type="Market",
time_in_force="FOK",
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
option_strategy_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
price=31.33,
)
OrderTypeStrict
TimeInForceStrict
str
str
str
The ID of the account to execute the strategy in.
str
Option strategy id obtained from response when creating option strategy object
Price
/accounts/{accountId}/optionStrategy/{optionStrategyId}/execute
post
snaptrade.reference_data.get_currency_exchange_rate_pair
Returns an Exchange Rate Pair object for the specified Currency Pair.
get_currency_exchange_rate_pair_response = (
snaptrade.reference_data.get_currency_exchange_rate_pair(
currency_pair="currencyPair_example",
)
)
str
A currency pair based on currency code for example, {CAD-USD}
/currencies/rates/{currencyPair}
get
snaptrade.reference_data.get_partner_info
Returns configurations for your SnapTrade Client ID, including allowed brokerages and data access.
get_partner_info_response = snaptrade.reference_data.get_partner_info()
/snapTrade/partners
get
snaptrade.reference_data.get_security_types
Return all available security types supported by SnapTrade.
get_security_types_response = snaptrade.reference_data.get_security_types()
/securityTypes
get
snaptrade.reference_data.get_stock_exchanges
Returns a list of all supported Exchanges.
get_stock_exchanges_response = snaptrade.reference_data.get_stock_exchanges()
/exchanges
get
snaptrade.reference_data.get_symbols
Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned.
get_symbols_response = snaptrade.reference_data.get_symbols(
substring="AAPL",
)
str
The search query for symbols.
/symbols
post
snaptrade.reference_data.get_symbols_by_ticker
Returns the Universal Symbol object specified by the ticker or the Universal Symbol ID. When a ticker is specified, the first matching result is returned. We largely follow the Yahoo Finance ticker format(click on "Yahoo Finance Market Coverage and Data Delays"). For example, for securities traded on the Toronto Stock Exchange, the symbol has a '.TO' suffix. For securities traded on NASDAQ or NYSE, the symbol does not have a suffix. Please use the ticker with the proper suffix for the best results.
get_symbols_by_ticker_response = snaptrade.reference_data.get_symbols_by_ticker(
query="query_example",
)
str
The ticker or Universal Symbol ID to look up the symbol with.
/symbols/{query}
get
snaptrade.reference_data.list_all_brokerage_authorization_type
Returns a list of all defined Brokerage authorization Type objects.
list_all_brokerage_authorization_type_response = (
snaptrade.reference_data.list_all_brokerage_authorization_type(
brokerage="QUESTRADE,ALPACA",
)
)
str
Comma separated value of brokerage slugs
BrokerageAuthorizationTypeReadOnly
/brokerageAuthorizationTypes
get
snaptrade.reference_data.list_all_brokerages
Returns a list of all defined Brokerage objects.
list_all_brokerages_response = snaptrade.reference_data.list_all_brokerages()
/brokerages
get
snaptrade.reference_data.list_all_currencies
Returns a list of all defined Currency objects.
list_all_currencies_response = snaptrade.reference_data.list_all_currencies()
/currencies
get
snaptrade.reference_data.list_all_currencies_rates
Returns a list of all Exchange Rate Pairs for all supported Currencies.
list_all_currencies_rates_response = (
snaptrade.reference_data.list_all_currencies_rates()
)
/currencies/rates
get
snaptrade.reference_data.symbol_search_user_account
Returns a list of Universal Symbol objects that match the given query. The matching takes into consideration both the ticker and the name of the symbol. Only the first 20 results are returned.
The search results are further limited to the symbols supported by the brokerage for which the account is under.
symbol_search_user_account_response = (
snaptrade.reference_data.symbol_search_user_account(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
substring="AAPL",
)
)
str
str
str
str
The search query for symbols.
/accounts/{accountId}/symbols
post
snaptrade.trading.cancel_user_account_order
Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected.
cancel_user_account_order_response = snaptrade.trading.cancel_user_account_order(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
brokerage_order_id="66a033fa-da74-4fcf-b527-feefdec9257e",
)
str
str
str
str
Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
/accounts/{accountId}/orders/cancel
post
snaptrade.trading.get_order_impact
Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a Trade
object and the ID of the object can be used to place the order with the brokerage using the place checked order endpoint. Please note that the Trade
object returned expires after 5 minutes. Any order placed using an expired Trade
will be rejected.
get_order_impact_response = snaptrade.trading.get_order_impact(
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
action="BUY",
universal_symbol_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
order_type="Market",
time_in_force="FOK",
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
price=31.33,
stop=31.33,
units=10.5,
notional_value=None,
)
str
Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
ActionStrict
str
Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls.
OrderTypeStrict
TimeInForceStrict
str
str
Optional[Union[int, float]]
The limit price for Limit
and StopLimit
orders.
Optional[Union[int, float]]
The price at which a stop order is triggered for Stop
and StopLimit
orders.
UnitsNullable
NotionalValueNullable
/trade/impact
post
snaptrade.trading.get_user_account_quotes
Returns quotes from the brokerage for the specified symbols and account. The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint. This endpoint does not work for options quotes.
get_user_account_quotes_response = snaptrade.trading.get_user_account_quotes(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
symbols="symbols_example",
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
use_ticker=True,
)
str
str
str
List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator
str
bool
Should be set to True
if symbols
are comprised of tickers. Defaults to False
if not provided.
/accounts/{accountId}/quotes
get
snaptrade.trading.place_force_order
Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds.
This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the check order impact endpoint.
It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the manual refresh endpoint for this.
place_force_order_response = snaptrade.trading.place_force_order(
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
action="BUY",
order_type="Market",
time_in_force="FOK",
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
universal_symbol_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
symbol="AAPL 131124C00240000",
price=31.33,
stop=31.33,
units=10.5,
notional_value=None,
)
str
Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
ActionStrictWithOptions
OrderTypeStrict
TimeInForceStrict
str
str
UniversalSymbolIDNullable
The universal symbol ID of the security to trade. Must be 'null' if symbol
is provided, otherwise must be provided.
Optional[str]
The security's trading ticker symbol. This currently only support Options symbols in the 21 character OCC format. For example \"AAPL 131124C00240000\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see here. If 'symbol' is provided, then 'universal_symbol_id' must be 'null'.
Optional[Union[int, float]]
The limit price for Limit
and StopLimit
orders.
Optional[Union[int, float]]
The price at which a stop order is triggered for Stop
and StopLimit
orders.
Union[int, float]
For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be null
if notional_value
is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares).
NotionalValueNullable
/trade/place
post
snaptrade.trading.place_order
Places the previously checked order with the brokerage. The tradeId
is obtained from the check order impact endpoint. If you prefer to place the order without checking for impact first, you can use the place order endpoint.
It's recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the manual refresh endpoint for this.
place_order_response = snaptrade.trading.place_order(
trade_id="139e307a-82f7-4402-b39e-4da7baa87758",
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
wait_to_confirm=True,
)
str
Obtained from calling the check order impact endpoint
str
str
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.
/trade/{tradeId}
post
snaptrade.transactions_and_reporting.get_activities
Returns all historical transactions for the specified user and filtering criteria. It's recommended to use startDate
and endDate
to paginate through the data, as the response may be very large for accounts with a long history and/or a lot of activity. There's a max number of 10000 transactions returned per request.
There is no guarantee to the ordering of the transactions returned. Please sort the transactions based on the trade_date
field if you need them in a specific order.
The data returned here is always cached and refreshed once a day. If you need real-time data, please use the manual refresh endpoint.
get_activities_response = snaptrade.transactions_and_reporting.get_activities(
user_id="snaptrade-user-123",
user_secret="adf2aa34-8219-40f7-a6b3-60156985cc61",
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="BUY,SELL,DIVIDEND",
)
str
str
date
The start date (inclusive) of the transaction history to retrieve. If not provided, the default is the first transaction known to SnapTrade based on trade_date
.
date
The end date (inclusive) of the transaction history to retrieve. If not provided, the default is the last transaction known to SnapTrade based on trade_date
.
str
Optional comma separated list of SnapTrade Account IDs used to filter the request to specific accounts. If not provided, the default is all known brokerage accounts for the user. The brokerageAuthorizations
parameter takes precedence over this parameter.
str
Optional comma separated list of SnapTrade Connection (Brokerage Authorization) IDs used to filter the request to only accounts that belong to those connections. If not provided, the default is all connections for the user. This parameter takes precedence over the accounts
parameter.
str
Optional comma separated list of transaction types to filter by. SnapTrade does a best effort to categorize brokerage transaction types into a common set of values. Here are some of the most popular values: - BUY
- Asset bought. - SELL
- Asset sold. - DIVIDEND
- Dividend payout. - CONTRIBUTION
- Cash contribution. - WITHDRAWAL
- Cash withdrawal. - REI
- Dividend reinvestment. - INTEREST
- Interest deposited into the account. - FEE
- Fee withdrawn from the account. - OPTIONEXPIRATION
- Option expiration event. - OPTIONASSIGNMENT
- Option assignment event. - OPTIONEXERCISE
- Option exercise event. - TRANSFER
- Transfer of assets from one account to another
/activities
get
snaptrade.transactions_and_reporting.get_reporting_custom_range
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.
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="adf2aa34-8219-40f7-a6b3-60156985cc61",
accounts="917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
detailed=True,
frequency="monthly",
)
date
date
str
str
str
Optional comma separated list of account IDs used to filter the request on specific accounts
bool
Optional, increases frequency of data points for the total value and contribution charts if set to true
str
Optional frequency for the rate of return chart (defaults to monthly). Possible values are daily, weekly, monthly, quarterly, yearly.
/performance/custom
get
This Python package is automatically generated by Konfig
FAQs
Client for SnapTrade
We found that snaptrade-python-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.