SnapTrade
Project description
snaptrade-python-sdk
Connect brokerage accounts to your app for live positions and trading
- API version: 1.0.0
- Package version: 10.2.0
Requirements.
Python >=3.7
Installation & Usage
pip install
If the python package is hosted on a repository, you can install directly using:
pip install snaptrade-python-sdk==10.2.0
(you may need to run pip
with root permission: sudo pip install snaptrade-python-sdk==10.2.0
)
Then import the package:
import snaptrade_client
Getting Started
Please follow the installation procedure and then run the following:
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)
snaptrade.api_disclaimer.accept(query_params={"userId": user_id, "userSecret": user_secret}, body={"accepted": True})
# 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)
Documentation for API Endpoints
All URIs are relative to https://api.snaptrade.com/api/v1
Class | Method | HTTP request | Description |
---|---|---|---|
APIDisclaimerApi | accept | post /snapTrade/acceptDisclaimer | Accept or Reject SnapTrade disclaimer agreement |
APIStatusApi | check | get / | Get API Status |
AccountInformationApi | get_all_user_holdings | get /holdings | List all accounts for the user, plus balances and positions for each account. |
AccountInformationApi | get_user_account_balance | get /accounts/{accountId}/balances | Get all cash balances of an investment account |
AccountInformationApi | get_user_account_details | get /accounts/{accountId} | Return details of a specific investment account |
AccountInformationApi | get_user_account_orders | get /accounts/{accountId}/orders | Get all history of orders placed in account |
AccountInformationApi | get_user_account_positions | get /accounts/{accountId}/positions | Get all positions of an investment account |
AccountInformationApi | get_user_holdings | get /accounts/{accountId}/holdings | List balances, positions and orders for the specified account. |
AccountInformationApi | list_user_accounts | get /accounts | List all investment accounts for the user |
AccountInformationApi | update_user_account | put /accounts/{accountId} | Update details of an investment account |
AuthenticationApi | delete_snap_trade_user | delete /snapTrade/deleteUser | Delete user from SnapTrade, disabling all brokerage authorizations and permanently deleting all data associated with the user |
AuthenticationApi | get_user_jwt | get /snapTrade/encryptedJWT | Obtains an encrypted JWT tokens that should be decrypted on a user's local device |
AuthenticationApi | list_snap_trade_users | get /snapTrade/listUsers | Get a list of all SnapTrade users you've registered on our platform |
AuthenticationApi | login_snap_trade_user | post /snapTrade/login | Generate a redirect URI to securely login a user to the SnapTrade Connection Portal |
AuthenticationApi | register_snap_trade_user | post /snapTrade/registerUser | Register user with SnapTrade in order to create secure brokerage authorizations |
ConnectionsApi | detail_brokerage_authorization | get /authorizations/{authorizationId} | Get detail of a specific brokerage authorizations for the user |
ConnectionsApi | list_brokerage_authorizations | get /authorizations | List all brokerage authorizations for the user |
ConnectionsApi | remove_brokerage_authorization | delete /authorizations/{authorizationId} | Remove a brokerage authorization. |
ConnectionsApi | session_events | get /sessionEvents | List all session events for the partner |
ErrorLogsApi | list_user_errors | get /snapTrade/listUserErrors | Retrieve error logs on behalf of your SnapTrade users |
OptionsApi | get_option_strategy | post /accounts/{accountId}/optionStrategy | Creates an option strategy object that will be used to place an option strategy order |
OptionsApi | get_options_chain | get /accounts/{accountId}/optionsChain | Get the options chain |
OptionsApi | get_options_strategy_quote | get /accounts/{accountId}/optionStrategy/{optionStrategyId} | Get latest market data of option strategy |
OptionsApi | list_option_holdings | get /accounts/{accountId}/options | Get the options holdings in the account |
OptionsApi | place_option_strategy | post /accounts/{accountId}/optionStrategy/{optionStrategyId}/execute | Place an option strategy order on the brokerage |
PortfolioManagementApi | add_portfolio_excluded_asset | post /portfolioGroups/{portfolioGroupId}/excludedassets | Adds an asset to exclude to a portfolio group |
PortfolioManagementApi | create | post /portfolioGroups | Create new portfolio group |
PortfolioManagementApi | create_asset_class | post /modelAssetClass | Create a new model asset class |
PortfolioManagementApi | create_model_portfolio | post /modelPortfolio | Creates a new model portfolio |
PortfolioManagementApi | delete_asset_class | delete /modelAssetClass/{modelAssetClassId} | Deletes a model asset class |
PortfolioManagementApi | delete_excluded_asset | delete /portfolioGroups/{portfolioGroupId}/excludedassets/{symbolId} | Unexclude an asset from a portfolio group |
PortfolioManagementApi | delete_model_portfolio_by_id | delete /modelPortfolio/{modelPortfolioId} | Deletes a model portfolio |
PortfolioManagementApi | delete_portfoli | delete /portfolioGroups/{portfolioGroupId} | Remove a target portfolio. |
PortfolioManagementApi | delete_portfolio_target_by_id | delete /portfolioGroups/{portfolioGroupId}/targets/{targetAssetId} | Remove a TargetAsset. |
PortfolioManagementApi | detail_asset_class | get /modelAssetClass/{modelAssetClassId} | Get details of a model asset class |
PortfolioManagementApi | get_calculated_trade_by_id | get /portfolioGroups/{portfolioGroupId}/calculatedtrades/{calculatedTradeId}/{TradeId} | Return an individual trade |
PortfolioManagementApi | get_model_details_by_id | get /modelPortfolio/{modelPortfolioId} | Get details of a model portfolio |
PortfolioManagementApi | get_portfolio_balances | get /portfolioGroups/{portfolioGroupId}/balances | Get sum of cash balances in portfolio group |
PortfolioManagementApi | get_portfolio_details_by_id | get /portfolioGroups/{portfolioGroupId} | Get details of a target portfolio |
PortfolioManagementApi | get_portfolio_info | get /portfolioGroups/{portfolioGroupId}/info | Return a whole bunch of relevant information relating to a portfolio group. |
PortfolioManagementApi | get_portfolio_positions | get /portfolioGroups/{portfolioGroupId}/positions | Get total of each postions owned in portfolio group |
PortfolioManagementApi | get_portfolio_settings | get /portfolioGroups/{portfolioGroupId}/settings | Get portfolio group settings |
PortfolioManagementApi | get_portfolio_target_by_id | get /portfolioGroups/{portfolioGroupId}/targets/{targetAssetId} | Get a specific target from a portfolio group |
PortfolioManagementApi | get_portfolio_targets | get /portfolioGroups/{portfolioGroupId}/targets | Get all target assets under the specified PortfolioGroup. |
PortfolioManagementApi | get_portoflio_excluded_assets | get /portfolioGroups/{portfolioGroupId}/excludedassets | Get an array of excluded assets associated with a portfolio group\ |
PortfolioManagementApi | import_model_portfolio | post /portfolioGroups/{portfolioGroupId}/import | Import target allocation based on portfolio group |
PortfolioManagementApi | list | get /portfolioGroups | List all portfolio groups |
PortfolioManagementApi | list_asset_classes | get /modelAssetClass | List of model asset class |
PortfolioManagementApi | list_calculated_trades | get /portfolioGroups/{portfolioGroupId}/calculatedtrades | List of trades to make to rebalance portfolio group |
PortfolioManagementApi | list_model_portfolio | get /modelPortfolio | List of model portfolio |
PortfolioManagementApi | list_portfolio_accounts | get /portfolioGroups/{portfolioGroupId}/accounts | Get all accounts associated with a portfolio group |
PortfolioManagementApi | modify_model_portfolio_by_id | post /modelPortfolio/{modelPortfolioId} | Updates model portfolio object |
PortfolioManagementApi | save_portfolio | patch /portfolioGroups/{portfolioGroupId} | Update an existing target portfolio. |
PortfolioManagementApi | search_portfolio_symbols | post /portfolioGroups/{portfolioGroupId}/symbols | Search for symbols limited to brokerages under the specified portfolio group |
PortfolioManagementApi | set_portfolio_targets | post /portfolioGroups/{portfolioGroupId}/targets | Set a new list of target assets under the specified PortfolioGroup. All existing target assets under this portfolio group will be replaced with the new list. |
PortfolioManagementApi | update_asset_class | post /modelAssetClass/{modelAssetClassId} | Updates model asset class objects |
PortfolioManagementApi | update_portfolio_settings | patch /portfolioGroups/{portfolioGroupId}/settings | Updates portfolio group settings |
PortfolioManagementApi | update_portfolio_target_by_id | patch /portfolioGroups/{portfolioGroupId}/targets/{targetAssetId} | Update a TargetAsset under the specified PortfolioGroup. |
ReferenceDataApi | get_currency_exchange_rate_pair | get /currencies/rates/{currencyPair} | Return the exchange rate of a currency pair |
ReferenceDataApi | get_partner_info | get /snapTrade/partners | Get metadata related to Snaptrade partner |
ReferenceDataApi | get_security_types | get /securityTypes | List of all security types. |
ReferenceDataApi | get_stock_exchanges | get /exchanges | Return list of stock exchanges on Passiv and their suffixes |
ReferenceDataApi | get_symbols | post /symbols | Search for symbols |
ReferenceDataApi | get_symbols_by_ticker | get /symbols/{ticker} | Get details of a symbol by the ticker |
ReferenceDataApi | list_all_brokerage_authorization_type | get /brokerageAuthorizationTypes | List of all brokerage authorization types |
ReferenceDataApi | list_all_brokerages | get /brokerages | List of all brokerages. |
ReferenceDataApi | list_all_currencies | get /currencies | List of all supported currencies |
ReferenceDataApi | list_all_currencies_rates | get /currencies/rates | Return the exchange rates of all supported currencies |
ReferenceDataApi | symbol_search_user_account | post /accounts/{accountId}/symbols | Search for symbols that are supported by a brokerage account using a substring |
TradingApi | cancel_user_account_order | post /accounts/{accountId}/orders/cancel | Cancel open order in account |
TradingApi | get_calculated_trade_impact_by_id | get /portfolioGroups/{portfolioGroupId}/calculatedtrades/{calculatedTradeId}/modify/{tradeId} | Return details of a specific trade before it's placed |
TradingApi | get_calculated_trades_impact | get /portfolioGroups/{portfolioGroupId}/calculatedtrades/{calculatedTradeId}/impact | Return the impact of placing a series of trades on the portfolio |
TradingApi | get_order_impact | post /trade/impact | Check impact of trades on account. |
TradingApi | get_user_account_quotes | get /accounts/{accountId}/quotes | Get symbol quotes |
TradingApi | modify_calculated_trade_by_id | patch /portfolioGroups/{portfolioGroupId}/calculatedtrades/{calculatedTradeId}/modify/{tradeId} | Modify units of a trade before it is placed |
TradingApi | place_calculated_trades | post /portfolioGroups/{portfolioGroupId}/calculatedtrades/{calculatedTradeId}/placeOrders | Place orders for the CalculatedTrades in series |
TradingApi | place_force_order | post /trade/place | Place a trade with NO validation. |
TradingApi | place_oco_order | post /trade/oco | Place a OCO (One Cancels Other) order |
TradingApi | place_order | post /trade/{tradeId} | Place order |
TransactionsAndReportingApi | get_activities | get /activities | Get transaction history for a user |
TransactionsAndReportingApi | get_reporting_custom_range | get /performance/custom | Get performance information for a specific timeframe |
Documentation For Models
- Account
- AccountHoldings
- AccountIDs
- AccountOrderRecord
- AccountOrderRecordStatus
- AccountSimple
- AccountSyncStatus
- Action
- Balance
- Brokerage
- BrokerageAuthIDs
- BrokerageAuthorization
- BrokerageAuthorizationType
- BrokerageAuthorizationTypeReadOnly
- BrokerageSymbol
- BrokerageType
- CalculatedTrade
- Cash
- CashRestriction
- ClientID
- ConsumerKey
- Currency
- DeleteUserResponse
- DividendAtDate
- EncryptedResponse
- Exchange
- ExchangeRatePairs
- ExcludedAsset
- Id
- JWT
- LoginRedirectURI
- ManualTrade
- ManualTradeAndImpact
- ManualTradeBalance
- ManualTradeForm
- ManualTradeSymbol
- Model400FailedRequestResponse
- Model401FailedRequestResponse
- Model403FailedRequestResponse
- Model404FailedRequestResponse
- ModelAssetClass
- ModelAssetClassDetails
- ModelAssetClassTarget
- ModelPortfolio
- ModelPortfolioAssetClass
- ModelPortfolioDetails
- ModelPortfolioSecurity
- MonthlyDividends
- NetContributions
- NetDividend
- OptionChain
- OptionLeg
- OptionStrategy
- OptionsHoldings
- OptionsPosition
- OptionsSymbol
- OrderType
- PartnerData
- PastValue
- Percent
- PerformanceCustom
- PortfolioGroup
- PortfolioGroupInfo
- PortfolioGroupPosition
- PortfolioGroupSettings
- Position
- PositionSymbol
- Price
- RedirectTokenandPin
- ReportingDate
- ReportingFrequency
- RsaPublicKey
- SecurityType
- SessionEvent
- Signature
- SignedContent
- SnapTradeAPIDisclaimerAcceptStatus
- SnapTradeHoldingsAccount
- SnapTradeHoldingsTotalValue
- SnapTradeLoginUserRequestBody
- SnapTradeRegisterUserRequestBody
- SnapTradeUserID
- SnapTradeUserSecret
- Status
- StopPrice
- StrategyImpact
- StrategyOrderPlace
- StrategyOrderQuotes
- StrategyOrderRecord
- StrategyQuotes
- SubPeriodReturnRate
- Symbol
- SymbolQuery
- SymbolsQuotes
- SyncStatusDate
- TargetAsset
- TargetAssetList
- Time
- TimeInForce
- Timestamp
- Trade
- TradeExecutionStatus
- TradeImpact
- TransactionsStatus
- USExchange
- UnderlyingSymbol
- Units
- UniversalActivity
- UniversalSymbol
- UniversalSymbolTicker
- UserErrorLog
- UserID
- UserIDandSecret
- UserList
- UserSecret
- UserSettings
Documentation For Authorization
Authentication schemes defined for the API:
PartnerClientId
- Type: API key
- API key parameter name: clientId
- Location: URL query string
PartnerSignature
- Type: API key
- API key parameter name: Signature
- Location: HTTP header
PartnerTimestamp
- Type: API key
- API key parameter name: timestamp
- Location: URL query string
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-10.2.0.tar.gz
(163.4 kB
view hashes)
Built Distribution
Close
Hashes for snaptrade-python-sdk-10.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed96b243c26564d24bf724bae3c546e050867ef0abd6dc760ee45ff96ddf46f3 |
|
MD5 | c246fedcae8ace4462a8e3a0e857d98b |
|
BLAKE2b-256 | e06542c46ed4284a1aac7ff8f2de5ffa188235589dbb811e77cbd91f629e1bf2 |
Close
Hashes for snaptrade_python_sdk-10.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2295e0eb5a2e9c59925fa74c2555b6a1e51b093463e0d7a9b22285929dbefb3b |
|
MD5 | b4eece9acdcc8d9a5da354801d22bf73 |
|
BLAKE2b-256 | 19318a117c037917fe054b223a4f5ba9bd1e6f6777e8a28b18f679b1db097357 |