Client for SnapTrade
Project description
Table of Contents
- Requirements
- Installing
- Getting Started
- Async
- Reference
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_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.get_user_jwt
snaptrade.authentication.list_snap_trade_users
snaptrade.authentication.login_snap_trade_user
snaptrade.authentication.register_snap_trade_user
snaptrade.connections.detail_brokerage_authorization
snaptrade.connections.list_brokerage_authorizations
snaptrade.connections.remove_brokerage_authorization
snaptrade.connections.session_events
snaptrade.error_logs.list_user_errors
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_oco_order
snaptrade.trading.place_order
snaptrade.transactions_and_reporting.get_activities
snaptrade.transactions_and_reporting.get_reporting_custom_range
Requirements
Python >=3.7
Installing
pip install snaptrade-python-sdk==10.34.2
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)
snaptrade.portfolio_management.create(
query_params={"userId": user_id, "userSecret": user_secret},
body={"id": str(uuid.uuid4()), "name": "MyPortfolio"},
)
res = snaptrade.portfolio_management.list(
query_params={"userId": user_id, "userSecret": user_secret}
)
pprint(res.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="John.doe@snaptrade.com",
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
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="John.doe@snaptrade.com",
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
๐ Endpoint
/holdings
get
๐ Back to Table of Contents
snaptrade.account_information.get_user_account_balance
List account balances
๐ ๏ธ Usage
get_user_account_balance_response = (
snaptrade.account_information.get_user_account_balance(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
account_id="accountId_example",
)
)
โ๏ธ Parameters
user_id: str
user_secret: str
account_id: str
The ID of the account to get balances.
๐ Return
๐ Endpoint
/accounts/{accountId}/balances
get
๐ Back to Table of Contents
snaptrade.account_information.get_user_account_details
Return details of a specific investment account
๐ ๏ธ Usage
get_user_account_details_response = (
snaptrade.account_information.get_user_account_details(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
account_id="accountId_example",
)
)
โ๏ธ Parameters
user_id: str
user_secret: str
account_id: str
The ID of the account to get detail of.
๐ Return
๐ Endpoint
/accounts/{accountId}
get
๐ Back to Table of Contents
snaptrade.account_information.get_user_account_orders
Get history of orders placed in account
๐ ๏ธ Usage
get_user_account_orders_response = (
snaptrade.account_information.get_user_account_orders(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
account_id="accountId_example",
state="all",
)
)
โ๏ธ 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"
๐ Return
๐ Endpoint
/accounts/{accountId}/orders
get
๐ Back to Table of Contents
snaptrade.account_information.get_user_account_positions
List account positions
๐ ๏ธ Usage
get_user_account_positions_response = (
snaptrade.account_information.get_user_account_positions(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
account_id="accountId_example",
)
)
โ๏ธ Parameters
user_id: str
user_secret: str
account_id: str
The ID of the account to get positions.
๐ Return
๐ Endpoint
/accounts/{accountId}/positions
get
๐ Back to Table of Contents
snaptrade.account_information.get_user_holdings
List balances, positions and orders for the specified account.
๐ ๏ธ Usage
get_user_holdings_response = snaptrade.account_information.get_user_holdings(
account_id="917c8734-8470-4a3e-a18f-57c3f2ee6631",
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
)
โ๏ธ Parameters
account_id: str
The ID of the account to fetch holdings for.
user_id: str
user_secret: str
๐ Return
๐ Endpoint
/accounts/{accountId}/holdings
get
๐ Back to Table of Contents
snaptrade.account_information.list_user_accounts
List accounts
๐ ๏ธ Usage
list_user_accounts_response = snaptrade.account_information.list_user_accounts(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
)
โ๏ธ Parameters
user_id: str
user_secret: str
๐ Return
๐ Endpoint
/accounts
get
๐ Back to Table of Contents
snaptrade.account_information.update_user_account
Update details of an investment account
๐ ๏ธ Usage
update_user_account_response = snaptrade.account_information.update_user_account(
user_id="John.doe@snaptrade.com",
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
๐ 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
๐ Endpoint
/
get
๐ Back to Table of Contents
snaptrade.authentication.delete_snap_trade_user
Delete SnapTrade user
๐ ๏ธ Usage
delete_snap_trade_user_response = snaptrade.authentication.delete_snap_trade_user(
user_id="John.doe@snaptrade.com",
)
โ๏ธ Parameters
user_id: str
๐ Return
๐ Endpoint
/snapTrade/deleteUser
delete
๐ Back to Table of Contents
snaptrade.authentication.get_user_jwt
Generate encrypted JWT token
๐ ๏ธ Usage
get_user_jwt_response = snaptrade.authentication.get_user_jwt(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
)
โ๏ธ Parameters
user_id: str
user_secret: str
๐ Endpoint
/snapTrade/encryptedJWT
get
๐ Back to Table of Contents
snaptrade.authentication.list_snap_trade_users
List SnapTrade users
๐ ๏ธ Usage
list_snap_trade_users_response = snaptrade.authentication.list_snap_trade_users()
๐ Return
๐ Endpoint
/snapTrade/listUsers
get
๐ Back to Table of Contents
snaptrade.authentication.login_snap_trade_user
Login user & generate connection link
๐ ๏ธ Usage
login_snap_trade_user_response = snaptrade.authentication.login_snap_trade_user(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
broker="ALPACA",
immediate_redirect=True,
custom_redirect="https://snaptrade.com",
reconnect="8b5f262d-4bb9-365d-888a-202bd3b15fa1",
connection_type="read",
)
โ๏ธ Parameters
user_id: str
user_secret: str
broker: str
immediate_redirect: bool
custom_redirect: str
reconnect: str
connection_type: str
โ๏ธ Request Body
๐ Endpoint
/snapTrade/login
post
๐ Back to Table of Contents
snaptrade.authentication.register_snap_trade_user
Create SnapTrade user
๐ ๏ธ Usage
register_snap_trade_user_response = snaptrade.authentication.register_snap_trade_user(
user_id="snaptrade-user-123",
rsa_public_key="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC7vbqajDw4o6gJy8UtmIbkcpnkO3Kwc4qsEnSZp/TR+fQi62F79RHWmwKOtFmwteURgLbj7D/WGuNLGOfa/2vse3G2eHnHl5CB8ruRX9fBl/KgwCVr2JaEuUm66bBQeP5XeBotdR4cvX38uPYivCDdPjJ1QWPdspTBKcxeFbccDw==",
)
โ๏ธ Parameters
user_id: str
SnapTrade User ID. Provided by SnapTrade Partner. Can be any string, as long as it's unique to a user
rsa_public_key: str
Open SSH RSA public key
โ๏ธ Request Body
SnapTradeRegisterUserRequestBody
๐ Return
๐ Endpoint
/snapTrade/registerUser
post
๐ Back to Table of Contents
snaptrade.connections.detail_brokerage_authorization
Get brokerage authorization details
๐ ๏ธ Usage
detail_brokerage_authorization_response = (
snaptrade.connections.detail_brokerage_authorization(
authorization_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
)
)
โ๏ธ Parameters
authorization_id: str
The ID of a brokerage authorization object.
user_id: str
user_secret: str
๐ Return
๐ Endpoint
/authorizations/{authorizationId}
get
๐ Back to Table of Contents
snaptrade.connections.list_brokerage_authorizations
List all brokerage authorizations for the user
๐ ๏ธ Usage
list_brokerage_authorizations_response = (
snaptrade.connections.list_brokerage_authorizations(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
)
)
โ๏ธ Parameters
user_id: str
user_secret: str
๐ Return
๐ Endpoint
/authorizations
get
๐ Back to Table of Contents
snaptrade.connections.remove_brokerage_authorization
Delete brokerage authorization
๐ ๏ธ Usage
snaptrade.connections.remove_brokerage_authorization(
authorization_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
user_id="John.doe@snaptrade.com",
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
List all session events for the partner
๐ ๏ธ 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.error_logs.list_user_errors
Retrieve error logs on behalf of your SnapTrade users
๐ ๏ธ Usage
list_user_errors_response = snaptrade.error_logs.list_user_errors(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
)
โ๏ธ Parameters
user_id: str
user_secret: str
๐ Return
๐ Endpoint
/snapTrade/listUserErrors
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="John.doe@snaptrade.com",
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
๐ Return
๐ Endpoint
/accounts/{accountId}/optionStrategy
post
๐ Back to Table of Contents
snaptrade.options.get_options_chain
Get the options chain
๐ ๏ธ Usage
get_options_chain_response = snaptrade.options.get_options_chain(
user_id="John.doe@snaptrade.com",
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
๐ Endpoint
/accounts/{accountId}/optionsChain
get
๐ Back to Table of Contents
snaptrade.options.get_options_strategy_quote
Get latest market data of option strategy
๐ ๏ธ Usage
get_options_strategy_quote_response = snaptrade.options.get_options_strategy_quote(
user_id="John.doe@snaptrade.com",
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
๐ Endpoint
/accounts/{accountId}/optionStrategy/{optionStrategyId}
get
๐ Back to Table of Contents
snaptrade.options.list_option_holdings
Get the options holdings in the account
๐ ๏ธ Usage
list_option_holdings_response = snaptrade.options.list_option_holdings(
user_id="John.doe@snaptrade.com",
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
๐ Endpoint
/accounts/{accountId}/options
get
๐ Back to Table of Contents
snaptrade.options.place_option_strategy
Place an option strategy order on the brokerage
๐ ๏ธ Usage
place_option_strategy_response = snaptrade.options.place_option_strategy(
order_type="Limit",
time_in_force="DAY",
price=31.33,
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
account_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
option_strategy_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
)
โ๏ธ Parameters
order_type: str
time_in_force: str
price: Price
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
โ๏ธ Request Body
๐ Return
๐ Endpoint
/accounts/{accountId}/optionStrategy/{optionStrategyId}/execute
post
๐ Back to Table of Contents
snaptrade.reference_data.get_currency_exchange_rate_pair
Return the exchange rate of a 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
๐ Endpoint
/currencies/rates/{currencyPair}
get
๐ Back to Table of Contents
snaptrade.reference_data.get_partner_info
Get metadata related to Snaptrade partner
๐ ๏ธ Usage
get_partner_info_response = snaptrade.reference_data.get_partner_info()
๐ Return
๐ Endpoint
/snapTrade/partners
get
๐ Back to Table of Contents
snaptrade.reference_data.get_security_types
List of all security types.
๐ ๏ธ Usage
get_security_types_response = snaptrade.reference_data.get_security_types()
๐ Return
๐ Endpoint
/securityTypes
get
๐ Back to Table of Contents
snaptrade.reference_data.get_stock_exchanges
List exchanges
๐ ๏ธ Usage
get_stock_exchanges_response = snaptrade.reference_data.get_stock_exchanges()
๐ Return
๐ Endpoint
/exchanges
get
๐ Back to Table of Contents
snaptrade.reference_data.get_symbols
Search for symbols
๐ ๏ธ Usage
get_symbols_response = snaptrade.reference_data.get_symbols(
substring="apple",
)
โ๏ธ Parameters
substring: str
โ๏ธ Request Body
๐ Return
๐ Endpoint
/symbols
post
๐ Back to Table of Contents
snaptrade.reference_data.get_symbols_by_ticker
Get details of a symbol by the ticker
๐ ๏ธ Usage
get_symbols_by_ticker_response = snaptrade.reference_data.get_symbols_by_ticker(
ticker="ticker_example",
symbol_id="046b6c7f-0b8a-43b9-b35d-6489e6daee91",
)
โ๏ธ Parameters
ticker: str
The ticker of the UniversalSymbol to get.
symbol_id: str
OPTIONAL IN PATH Can be used instead of the ticker ; The ID of the UniversalSymbol to get.
๐ Return
๐ Endpoint
/symbols/{ticker}
get
๐ Back to Table of Contents
snaptrade.reference_data.list_all_brokerage_authorization_type
List of all brokerage authorization types
๐ ๏ธ 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
List brokerages
๐ ๏ธ Usage
list_all_brokerages_response = snaptrade.reference_data.list_all_brokerages()
๐ Return
๐ Endpoint
/brokerages
get
๐ Back to Table of Contents
snaptrade.reference_data.list_all_currencies
List currencies
๐ ๏ธ Usage
list_all_currencies_response = snaptrade.reference_data.list_all_currencies()
๐ Return
๐ Endpoint
/currencies
get
๐ Back to Table of Contents
snaptrade.reference_data.list_all_currencies_rates
List currency exchange rates
๐ ๏ธ Usage
list_all_currencies_rates_response = (
snaptrade.reference_data.list_all_currencies_rates()
)
๐ Return
๐ Endpoint
/currencies/rates
get
๐ Back to Table of Contents
snaptrade.reference_data.symbol_search_user_account
Search for symbols available in an account
๐ ๏ธ Usage
symbol_search_user_account_response = (
snaptrade.reference_data.symbol_search_user_account(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
account_id="accountId_example",
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
๐ Return
๐ Endpoint
/accounts/{accountId}/symbols
post
๐ Back to Table of Contents
snaptrade.trading.cancel_user_account_order
Cancel open order in account
๐ ๏ธ Usage
cancel_user_account_order_response = snaptrade.trading.cancel_user_account_order(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
account_id="accountId_example",
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
๐ Endpoint
/accounts/{accountId}/orders/cancel
post
๐ Back to Table of Contents
snaptrade.trading.get_order_impact
Check impact of trades on account.
๐ ๏ธ Usage
get_order_impact_response = snaptrade.trading.get_order_impact(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
account_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
action="BUY",
order_type="Limit",
price=31.33,
stop=31.33,
time_in_force="Day",
units=3.14,
universal_symbol_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
)
โ๏ธ Parameters
user_id: str
user_secret: str
account_id: str
action: Action
order_type: OrderType
price: Price
stop: StopPrice
time_in_force: TimeInForce
units: Union[int, float]
Trade Units
universal_symbol_id: str
โ๏ธ Request Body
๐ Return
๐ Endpoint
/trade/impact
post
๐ Back to Table of Contents
snaptrade.trading.get_user_account_quotes
Get symbol quotes
๐ ๏ธ Usage
get_user_account_quotes_response = snaptrade.trading.get_user_account_quotes(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
symbols="symbols_example",
account_id="accountId_example",
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
๐ Endpoint
/accounts/{accountId}/quotes
get
๐ Back to Table of Contents
snaptrade.trading.place_force_order
Place a trade with NO validation.
๐ ๏ธ Usage
place_force_order_response = snaptrade.trading.place_force_order(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
account_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
action="BUY",
order_type="Limit",
price=31.33,
stop=31.33,
time_in_force="Day",
units=3.14,
universal_symbol_id="2bcd7cc3-e922-4976-bce1-9858296801c3",
)
โ๏ธ Parameters
user_id: str
user_secret: str
account_id: str
action: Action
order_type: OrderType
price: Price
stop: StopPrice
time_in_force: TimeInForce
units: Union[int, float]
Trade Units
universal_symbol_id: str
โ๏ธ Request Body
๐ Return
๐ Endpoint
/trade/place
post
๐ Back to Table of Contents
snaptrade.trading.place_oco_order
Place a OCO (One Cancels Other) order
๐ ๏ธ Usage
place_oco_order_response = snaptrade.trading.place_oco_order(
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
first_trade_id=None,
second_trade_id=None,
)
โ๏ธ Parameters
user_id: str
user_secret: str
first_trade_id: Union[bool, date, datetime, dict, float, int, list, str, None]
The ID of first trade object obtained from trade/impact endpoint
second_trade_id: Union[bool, date, datetime, dict, float, int, list, str, None]
The ID of second trade object obtained from trade/impact endpoint
โ๏ธ Request Body
๐ Return
๐ Endpoint
/trade/oco
post
๐ Back to Table of Contents
snaptrade.trading.place_order
Place order
๐ ๏ธ Usage
place_order_response = snaptrade.trading.place_order(
trade_id="tradeId_example",
user_id="John.doe@snaptrade.com",
user_secret="USERSECRET123",
)
โ๏ธ Parameters
trade_id: str
The ID of trade object obtained from trade/impact endpoint
user_id: str
user_secret: str
๐ Return
๐ Endpoint
/trade/{tradeId}
post
๐ Back to Table of Contents
snaptrade.transactions_and_reporting.get_activities
Returns activities (transactions) for a user. Specifing start and end date is highly recommended for automatic calls for better performance
๐ ๏ธ Usage
get_activities_response = snaptrade.transactions_and_reporting.get_activities(
user_id="John.doe@snaptrade.com",
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
๐ Endpoint
/activities
get
๐ Back to Table of Contents
snaptrade.transactions_and_reporting.get_reporting_custom_range
Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Total Equity Timeframe and Rate of Returns are experimental and should not be trusted to be 100% accurate
๐ ๏ธ 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="John.doe@snaptrade.com",
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
๐ 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
Built Distribution
Hashes for snaptrade_python_sdk-10.34.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bef0f976b294aebbed79396af1543662760a84ea4449ec5bc29af9ae42b0d9b |
|
MD5 | f7d3e7df072afe92f2d6294a7a6f6663 |
|
BLAKE2b-256 | 90604402f2a571b7614e9b8be7cb5449d585dc3a57342bbdd9e5c6308a667a58 |
Hashes for snaptrade_python_sdk-10.34.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 693bfefb2dfe82109b0a301fa6d818e46c9c598719ab5f2a28599911f662fde3 |
|
MD5 | 7cb51028777807998c22ebfc6317cb42 |
|
BLAKE2b-256 | d0ef3079461c5a254036cd04a4b86859b9dcca3866ebcf7d6cd1c552ec301452 |