[![Visit SnapTrade](./header.png)](https://snaptrade.com) # [SnapTrade](https://snaptrade.com) Connect brokerage accounts to your app for live positions and trading [![npm](https://img.shields.io/badge/gem-v2.0.34-blue)](https://rubygems.org/gems/snaptrade/versions/2.0.34) [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/)
## Table of Contents - [Installation](#installation) - [Getting Started](#getting-started) - [Raw HTTP Response](#raw-http-response) - [Reference](#reference) * [`snaptrade.account_information.get_all_user_holdings`](#snaptradeaccount_informationget_all_user_holdings) * [`snaptrade.account_information.get_user_account_balance`](#snaptradeaccount_informationget_user_account_balance) * [`snaptrade.account_information.get_user_account_details`](#snaptradeaccount_informationget_user_account_details) * [`snaptrade.account_information.get_user_account_orders`](#snaptradeaccount_informationget_user_account_orders) * [`snaptrade.account_information.get_user_account_positions`](#snaptradeaccount_informationget_user_account_positions) * [`snaptrade.account_information.get_user_holdings`](#snaptradeaccount_informationget_user_holdings) * [`snaptrade.account_information.list_user_accounts`](#snaptradeaccount_informationlist_user_accounts) * [`snaptrade.account_information.update_user_account`](#snaptradeaccount_informationupdate_user_account) * [`snaptrade.api_status.check`](#snaptradeapi_statuscheck) * [`snaptrade.authentication.delete_snap_trade_user`](#snaptradeauthenticationdelete_snap_trade_user) * [`snaptrade.authentication.list_snap_trade_users`](#snaptradeauthenticationlist_snap_trade_users) * [`snaptrade.authentication.login_snap_trade_user`](#snaptradeauthenticationlogin_snap_trade_user) * [`snaptrade.authentication.register_snap_trade_user`](#snaptradeauthenticationregister_snap_trade_user) * [`snaptrade.authentication.reset_snap_trade_user_secret`](#snaptradeauthenticationreset_snap_trade_user_secret) * [`snaptrade.connections.detail_brokerage_authorization`](#snaptradeconnectionsdetail_brokerage_authorization) * [`snaptrade.connections.disable_brokerage_authorization`](#snaptradeconnectionsdisable_brokerage_authorization) * [`snaptrade.connections.list_brokerage_authorizations`](#snaptradeconnectionslist_brokerage_authorizations) * [`snaptrade.connections.refresh_brokerage_authorization`](#snaptradeconnectionsrefresh_brokerage_authorization) * [`snaptrade.connections.remove_brokerage_authorization`](#snaptradeconnectionsremove_brokerage_authorization) * [`snaptrade.connections.session_events`](#snaptradeconnectionssession_events) * [`snaptrade.options.get_option_strategy`](#snaptradeoptionsget_option_strategy) * [`snaptrade.options.get_options_chain`](#snaptradeoptionsget_options_chain) * [`snaptrade.options.get_options_strategy_quote`](#snaptradeoptionsget_options_strategy_quote) * [`snaptrade.options.list_option_holdings`](#snaptradeoptionslist_option_holdings) * [`snaptrade.options.place_option_strategy`](#snaptradeoptionsplace_option_strategy) * [`snaptrade.reference_data.get_currency_exchange_rate_pair`](#snaptradereference_dataget_currency_exchange_rate_pair) * [`snaptrade.reference_data.get_partner_info`](#snaptradereference_dataget_partner_info) * [`snaptrade.reference_data.get_security_types`](#snaptradereference_dataget_security_types) * [`snaptrade.reference_data.get_stock_exchanges`](#snaptradereference_dataget_stock_exchanges) * [`snaptrade.reference_data.get_symbols`](#snaptradereference_dataget_symbols) * [`snaptrade.reference_data.get_symbols_by_ticker`](#snaptradereference_dataget_symbols_by_ticker) * [`snaptrade.reference_data.list_all_brokerage_authorization_type`](#snaptradereference_datalist_all_brokerage_authorization_type) * [`snaptrade.reference_data.list_all_brokerages`](#snaptradereference_datalist_all_brokerages) * [`snaptrade.reference_data.list_all_currencies`](#snaptradereference_datalist_all_currencies) * [`snaptrade.reference_data.list_all_currencies_rates`](#snaptradereference_datalist_all_currencies_rates) * [`snaptrade.reference_data.symbol_search_user_account`](#snaptradereference_datasymbol_search_user_account) * [`snaptrade.trading.cancel_user_account_order`](#snaptradetradingcancel_user_account_order) * [`snaptrade.trading.get_order_impact`](#snaptradetradingget_order_impact) * [`snaptrade.trading.get_user_account_quotes`](#snaptradetradingget_user_account_quotes) * [`snaptrade.trading.place_force_order`](#snaptradetradingplace_force_order) * [`snaptrade.trading.place_order`](#snaptradetradingplace_order) * [`snaptrade.transactions_and_reporting.get_activities`](#snaptradetransactions_and_reportingget_activities) * [`snaptrade.transactions_and_reporting.get_reporting_custom_range`](#snaptradetransactions_and_reportingget_reporting_custom_range) ## Installation Add to Gemfile: ```ruby gem 'snaptrade', '~> 2.0.34' ``` ## Getting Started ```ruby require 'snaptrade' configuration = SnapTrade::Configuration.new configuration.client_id = ENV["SNAPTRADE_CLIENT_ID"] configuration.consumer_key = ENV["SNAPTRADE_CONSUMER_KEY"] snaptrade = SnapTrade::Client.new(configuration) result = snaptrade.account_information.get_all_user_holdings( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631", ) p result ``` ## Raw HTTP Response To access the raw HTTP response, suffix any method with `_with_http_info`. ```ruby result = snaptrade.account_information.get_all_user_holdings_with_http_info( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631", ) p result[0] # [Array] Deserialized data p.result[1] # [Integer] HTTP status code p.result[2] # [Hash] HTTP headers p.result[3] # [Faraday::Response] Raw HTTP response ``` ## Reference ### `snaptrade.account_information.get_all_user_holdings` ![Deprecated](https://img.shields.io/badge/deprecated-yellow) **Deprecated, please use the account-specific holdings endpoint instead.** List all accounts for the user, plus balances, positions, and orders for each account. #### πŸ› οΈ Usage ```ruby result = snaptrade.account_information.get_all_user_holdings( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### brokerage_authorizations: `String` Optional. Comma seperated list of authorization IDs (only use if filtering is needed on one or more authorizations). #### πŸ”„ Return [AccountHoldings](./lib/snaptrade/models/account_holdings.rb) #### 🌐 Endpoint `/holdings` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `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](https://www.questrade.com/learning/questrade-basics/balances-and-reports/understanding-your-account-balances). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) 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](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. #### πŸ› οΈ Usage ```ruby result = snaptrade.account_information.get_user_account_balance( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` #### πŸ”„ Return [Balance](./lib/snaptrade/models/balance.rb) #### 🌐 Endpoint `/accounts/{accountId}/balances` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `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](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. #### πŸ› οΈ Usage ```ruby result = snaptrade.account_information.get_user_account_details( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` #### πŸ”„ Return [Account](./lib/snaptrade/models/account.rb) #### 🌐 Endpoint `/accounts/{accountId}` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `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](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) 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](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. #### πŸ› οΈ Usage ```ruby result = 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, ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` ##### state: `String` defaults value is set to \"all\" ##### days: `Integer` 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](./lib/snaptrade/models/account_order_record.rb) #### 🌐 Endpoint `/accounts/{accountId}/orders` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `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](/reference/Options/Options_listOptionHoldings). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) 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](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. #### πŸ› οΈ Usage ```ruby result = snaptrade.account_information.get_user_account_positions( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` #### πŸ”„ Return [Position](./lib/snaptrade/models/position.rb) #### 🌐 Endpoint `/accounts/{accountId}/positions` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `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](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getUserAccountPositions) and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders) 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](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) 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](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. #### πŸ› οΈ Usage ```ruby result = snaptrade.account_information.get_user_holdings( account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", user_id: "snaptrade-user-123", user_secret: "USERSECRET123", ) p result ``` #### βš™οΈ Parameters ##### account_id: `String` ##### user_id: `String` ##### user_secret: `String` #### πŸ”„ Return [AccountHoldingsAccount](./lib/snaptrade/models/account_holdings_account.rb) #### 🌐 Endpoint `/accounts/{accountId}/holdings` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.account_information.list_user_accounts` Returns all brokerage accounts 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](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. #### πŸ› οΈ Usage ```ruby result = snaptrade.account_information.list_user_accounts( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` #### πŸ”„ Return [Account](./lib/snaptrade/models/account.rb) #### 🌐 Endpoint `/accounts` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.account_information.update_user_account` Updates various properties of a specified account. #### πŸ› οΈ Usage ```ruby result = snaptrade.account_information.update_user_account( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", account_id: "accountId_example", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` The ID of the account to update. #### πŸ”„ Return [Account](./lib/snaptrade/models/account.rb) #### 🌐 Endpoint `/accounts/{accountId}` `PUT` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.api_status.check` Check whether the API is operational and verify timestamps. #### πŸ› οΈ Usage ```ruby result = snaptrade.api_status.check p result ``` #### πŸ”„ Return [Status](./lib/snaptrade/models/status.rb) #### 🌐 Endpoint `/` `GET` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = snaptrade.authentication.delete_snap_trade_user( user_id: "snaptrade-user-123", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` #### πŸ”„ Return [DeleteUserResponse](./lib/snaptrade/models/delete_user_response.rb) #### 🌐 Endpoint `/snapTrade/deleteUser` `DELETE` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.authentication.list_snap_trade_users` Returns a list of users you've registered over the SnapTrade API. #### πŸ› οΈ Usage ```ruby result = snaptrade.authentication.list_snap_trade_users p result ``` #### 🌐 Endpoint `/snapTrade/listUsers` `GET` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = 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", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### broker: `String` Slug of the brokerage to connect the user to. See [this document](https://snaptrade.notion.site/SnapTrade-Brokerage-Integrations-f83946a714a84c3caf599f6a945f0ead) for a list of supported brokerages and their slugs. ##### immediateRedirect: `Boolean` When set to True, user will be redirected back to the partner's site instead of the connection portal ##### customRedirect: `String` URL to redirect the user to after the user connects their brokerage account ##### reconnect: `String` 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. ##### connectionType: [`ConnectionType`](./lib/snaptrade/models/connection_type.rb) Sets whether the connection should be read or trade ##### connectionPortalVersion: [`ConnectionPortalVersion`](./lib/snaptrade/models/connection_portal_version.rb) Sets the version of the connection portal to render, with a default to 'v3' #### πŸ”„ Return [AuthenticationLoginSnapTradeUser200Response](./lib/snaptrade/models/authentication_login_snap_trade_user200_response.rb) #### 🌐 Endpoint `/snapTrade/login` `POST` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = snaptrade.authentication.register_snap_trade_user( user_id: "snaptrade-user-123", ) p result ``` #### βš™οΈ Parameters ##### userId: `String` 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. #### πŸ”„ Return [UserIDandSecret](./lib/snaptrade/models/user_i_dand_secret.rb) #### 🌐 Endpoint `/snapTrade/registerUser` `POST` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = snaptrade.authentication.reset_snap_trade_user_secret( user_id: "snaptrade-user-123", user_secret: "h81@cx1lkalablakwjaltkejraj11=", ) p result ``` #### βš™οΈ Parameters ##### userId: `String` 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. ##### userSecret: `String` SnapTrade User Secret randomly generated by SnapTrade. This is privileged information and if compromised, should be rotated via the SnapTrade API. #### πŸ”„ Return [UserIDandSecret](./lib/snaptrade/models/user_i_dand_secret.rb) #### 🌐 Endpoint `/snapTrade/resetUserSecret` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.connections.detail_brokerage_authorization` Returns a single brokerage authorization object for the specified ID. #### πŸ› οΈ Usage ```ruby result = snaptrade.connections.detail_brokerage_authorization( authorization_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", user_id: "snaptrade-user-123", user_secret: "USERSECRET123", ) p result ``` #### βš™οΈ Parameters ##### authorization_id: `String` The ID of a brokerage authorization object. ##### user_id: `String` ##### user_secret: `String` #### πŸ”„ Return [BrokerageAuthorization](./lib/snaptrade/models/brokerage_authorization.rb) #### 🌐 Endpoint `/authorizations/{authorizationId}` `GET` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = snaptrade.connections.disable_brokerage_authorization( authorization_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", user_id: "snaptrade-user-123", user_secret: "USERSECRET123", ) p result ``` #### βš™οΈ Parameters ##### authorization_id: `String` The ID of a brokerage authorization object. ##### user_id: `String` ##### user_secret: `String` #### πŸ”„ Return [BrokerageAuthorizationDisabledConfirmation](./lib/snaptrade/models/brokerage_authorization_disabled_confirmation.rb) #### 🌐 Endpoint `/authorizations/{authorizationId}/disable` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.connections.list_brokerage_authorizations` Returns a list of Brokerage Authorization objects for the user #### πŸ› οΈ Usage ```ruby result = snaptrade.connections.list_brokerage_authorizations( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` #### πŸ”„ Return [BrokerageAuthorization](./lib/snaptrade/models/brokerage_authorization.rb) #### 🌐 Endpoint `/authorizations` `GET` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = snaptrade.connections.refresh_brokerage_authorization( authorization_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", user_id: "snaptrade-user-123", user_secret: "USERSECRET123", ) p result ``` #### βš™οΈ Parameters ##### authorization_id: `String` The ID of a brokerage authorization object. ##### user_id: `String` ##### user_secret: `String` #### πŸ”„ Return [BrokerageAuthorizationRefreshConfirmation](./lib/snaptrade/models/brokerage_authorization_refresh_confirmation.rb) #### 🌐 Endpoint `/authorizations/{authorizationId}/refresh` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.connections.remove_brokerage_authorization` Deletes a specified brokerage authorization given by the ID. #### πŸ› οΈ Usage ```ruby snaptrade.connections.remove_brokerage_authorization( authorization_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", user_id: "snaptrade-user-123", user_secret: "USERSECRET123", ) ``` #### βš™οΈ Parameters ##### authorization_id: `String` The ID of the Authorization to delete. ##### user_id: `String` ##### user_secret: `String` #### 🌐 Endpoint `/authorizations/{authorizationId}` `DELETE` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.connections.session_events` Returns a list of session events associated with a user. #### πŸ› οΈ Usage ```ruby result = 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", ) p result ``` #### βš™οΈ Parameters ##### partner_client_id: `String` ##### user_id: `String` Optional comma seperated list of user IDs used to filter the request on specific users ##### session_id: `String` Optional comma seperated list of session IDs used to filter the request on specific users #### πŸ”„ Return [ConnectionsSessionEvents200ResponseInner](./lib/snaptrade/models/connections_session_events200_response_inner.rb) #### 🌐 Endpoint `/sessionEvents` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.options.get_option_strategy` Creates an option strategy object that will be used to place an option strategy order. #### πŸ› οΈ Usage ```ruby result = 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", ) p result ``` #### βš™οΈ Parameters ##### underlying_symbol_id: `String` ##### legs: Array<[`OptionLeg`](./lib/snaptrade/models/option_leg.rb)> ##### strategy_type: [`StrategyType`](./lib/snaptrade/models/strategy_type.rb) ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` The ID of the account to create the option strategy object in. #### πŸ”„ Return [StrategyQuotes](./lib/snaptrade/models/strategy_quotes.rb) #### 🌐 Endpoint `/accounts/{accountId}/optionStrategy` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.options.get_options_chain` Returns the option chain for the specified symbol in the specified account. #### πŸ› οΈ Usage ```ruby result = snaptrade.options.get_options_chain( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", account_id: "accountId_example", symbol: "symbol_example", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` The ID of the account to get the options chain from. ##### symbol: `String` Universal symbol ID if symbol #### πŸ”„ Return [OptionChainInner](./lib/snaptrade/models/option_chain_inner.rb) #### 🌐 Endpoint `/accounts/{accountId}/optionsChain` `GET` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = 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", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` The ID of the account the strategy will be placed in. ##### option_strategy_id: `String` Option strategy id obtained from response when creating option strategy object #### πŸ”„ Return [StrategyQuotes](./lib/snaptrade/models/strategy_quotes.rb) #### 🌐 Endpoint `/accounts/{accountId}/optionStrategy/{optionStrategyId}` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `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](/reference/Account%20Information/AccountInformation_getUserAccountPositions). The data returned here is cached. How long the data is cached for varies by brokerage. Check the [brokerage integrations doc](https://snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=d16c4c97b8d5438bbb2d8581ac53b11e) 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](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint**. #### πŸ› οΈ Usage ```ruby result = snaptrade.options.list_option_holdings( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` #### πŸ”„ Return [OptionsPosition](./lib/snaptrade/models/options_position.rb) #### 🌐 Endpoint `/accounts/{accountId}/options` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.options.place_option_strategy` Places the option strategy order and returns the order record received from the brokerage. #### πŸ› οΈ Usage ```ruby result = 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, ) p result ``` #### βš™οΈ Parameters ##### order_type: [`OrderTypeStrict`](./lib/snaptrade/models/order_type_strict.rb) Order Type ##### time_in_force: [`TimeInForceStrict`](./lib/snaptrade/models/time_in_force_strict.rb) Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` The ID of the account to execute the strategy in. ##### option_strategy_id: `String` Option strategy id obtained from response when creating option strategy object ##### price: `Float` Trade Price if limit or stop limit order #### πŸ”„ Return [StrategyOrderRecord](./lib/snaptrade/models/strategy_order_record.rb) #### 🌐 Endpoint `/accounts/{accountId}/optionStrategy/{optionStrategyId}/execute` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.reference_data.get_currency_exchange_rate_pair` Returns an Exchange Rate Pair object for the specified Currency Pair. #### πŸ› οΈ Usage ```ruby result = snaptrade.reference_data.get_currency_exchange_rate_pair( currency_pair: "currencyPair_example", ) p result ``` #### βš™οΈ Parameters ##### currency_pair: `String` A currency pair based on currency code for example, {CAD-USD} #### πŸ”„ Return [ExchangeRatePairs](./lib/snaptrade/models/exchange_rate_pairs.rb) #### 🌐 Endpoint `/currencies/rates/{currencyPair}` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.reference_data.get_partner_info` Returns useful data related to the specified ClientID, including allowed brokerages and data access. #### πŸ› οΈ Usage ```ruby result = snaptrade.reference_data.get_partner_info p result ``` #### πŸ”„ Return [PartnerData](./lib/snaptrade/models/partner_data.rb) #### 🌐 Endpoint `/snapTrade/partners` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.reference_data.get_security_types` List security types available on SnapTrade. #### πŸ› οΈ Usage ```ruby result = snaptrade.reference_data.get_security_types p result ``` #### πŸ”„ Return [SecurityType](./lib/snaptrade/models/security_type.rb) #### 🌐 Endpoint `/securityTypes` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.reference_data.get_stock_exchanges` Returns a list of all supported Exchanges. #### πŸ› οΈ Usage ```ruby result = snaptrade.reference_data.get_stock_exchanges p result ``` #### πŸ”„ Return [Exchange](./lib/snaptrade/models/exchange.rb) #### 🌐 Endpoint `/exchanges` `GET` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = snaptrade.reference_data.get_symbols( substring: "apple", ) p result ``` #### βš™οΈ Parameters ##### substring: `String` #### πŸ”„ Return [UniversalSymbol](./lib/snaptrade/models/universal_symbol.rb) #### 🌐 Endpoint `/symbols` `POST` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = snaptrade.reference_data.get_symbols_by_ticker( query: "query_example", ) p result ``` #### βš™οΈ Parameters ##### query: `String` The ticker or universal_symbol_id of the UniversalSymbol to get. #### πŸ”„ Return [UniversalSymbol](./lib/snaptrade/models/universal_symbol.rb) #### 🌐 Endpoint `/symbols/{query}` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.reference_data.list_all_brokerage_authorization_type` Returns a list of all defined Brokerage authorization Type objects. #### πŸ› οΈ Usage ```ruby result = snaptrade.reference_data.list_all_brokerage_authorization_type( brokerage: "QUESTRADE,ALPACA", ) p result ``` #### βš™οΈ Parameters ##### brokerage: `String` Comma separated value of brokerage slugs #### πŸ”„ Return [BrokerageAuthorizationTypeReadOnly](./lib/snaptrade/models/brokerage_authorization_type_read_only.rb) #### 🌐 Endpoint `/brokerageAuthorizationTypes` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.reference_data.list_all_brokerages` Returns a list of all defined Brokerage objects. #### πŸ› οΈ Usage ```ruby result = snaptrade.reference_data.list_all_brokerages p result ``` #### πŸ”„ Return [Brokerage](./lib/snaptrade/models/brokerage.rb) #### 🌐 Endpoint `/brokerages` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.reference_data.list_all_currencies` Returns a list of all defined Currency objects. #### πŸ› οΈ Usage ```ruby result = snaptrade.reference_data.list_all_currencies p result ``` #### πŸ”„ Return [Currency](./lib/snaptrade/models/currency.rb) #### 🌐 Endpoint `/currencies` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.reference_data.list_all_currencies_rates` Returns a list of all Exchange Rate Pairs for all supported Currencies. #### πŸ› οΈ Usage ```ruby result = snaptrade.reference_data.list_all_currencies_rates p result ``` #### πŸ”„ Return [ExchangeRatePairs](./lib/snaptrade/models/exchange_rate_pairs.rb) #### 🌐 Endpoint `/currencies/rates` `GET` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = snaptrade.reference_data.symbol_search_user_account( user_id: "snaptrade-user-123", user_secret: "USERSECRET123", account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", substring: "apple", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` The ID of the account to search for symbols within. ##### substring: `String` #### πŸ”„ Return [UniversalSymbol](./lib/snaptrade/models/universal_symbol.rb) #### 🌐 Endpoint `/accounts/{accountId}/symbols` `POST` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = 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", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` The ID of the account to cancel the order in. ##### brokerage_order_id: `String` #### πŸ”„ Return [AccountOrderRecord](./lib/snaptrade/models/account_order_record.rb) #### 🌐 Endpoint `/accounts/{accountId}/orders/cancel` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.trading.get_order_impact` Return the trade object and it's impact on the account for the specified order. #### πŸ› οΈ Usage ```ruby result = 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, ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` ##### action: [`ActionStrict`](./lib/snaptrade/models/action_strict.rb) Trade Action ##### order_type: [`OrderTypeStrict`](./lib/snaptrade/models/order_type_strict.rb) Order Type ##### price: `Float` Trade Price if limit or stop limit order ##### stop: `Float` Stop Price. If stop loss or stop limit order, the price to trigger the stop ##### time_in_force: [`TimeInForceStrict`](./lib/snaptrade/models/time_in_force_strict.rb) Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled ##### units: [`Float`](./lib/snaptrade/models/float.rb) ##### universal_symbol_id: `String` ##### notional_value: [`ManualTradeFormNotionalValue`](./lib/snaptrade/models/manual_trade_form_notional_value.rb) #### πŸ”„ Return [ManualTradeAndImpact](./lib/snaptrade/models/manual_trade_and_impact.rb) #### 🌐 Endpoint `/trade/impact` `POST` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.trading.get_user_account_quotes` Returns quote(s) from the brokerage for the specified symbol(s). #### πŸ› οΈ Usage ```ruby result = 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, ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### symbols: `String` List of universal_symbol_id or tickers to get quotes for. ##### account_id: `String` The ID of the account to get quotes. ##### use_ticker: `Boolean` Should be set to True if providing tickers. #### πŸ”„ Return [SymbolsQuotesInner](./lib/snaptrade/models/symbols_quotes_inner.rb) #### 🌐 Endpoint `/accounts/{accountId}/quotes` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.trading.place_force_order` Places a specified trade in the specified account. #### πŸ› οΈ Usage ```ruby result = 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, ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### account_id: `String` ##### action: [`ActionStrict`](./lib/snaptrade/models/action_strict.rb) Trade Action ##### order_type: [`OrderTypeStrict`](./lib/snaptrade/models/order_type_strict.rb) Order Type ##### price: `Float` Trade Price if limit or stop limit order ##### stop: `Float` Stop Price. If stop loss or stop limit order, the price to trigger the stop ##### time_in_force: [`TimeInForceStrict`](./lib/snaptrade/models/time_in_force_strict.rb) Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled ##### units: [`Float`](./lib/snaptrade/models/float.rb) ##### universal_symbol_id: `String` ##### notional_value: [`ManualTradeFormNotionalValue`](./lib/snaptrade/models/manual_trade_form_notional_value.rb) #### πŸ”„ Return [AccountOrderRecord](./lib/snaptrade/models/account_order_record.rb) #### 🌐 Endpoint `/trade/place` `POST` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = snaptrade.trading.place_order( trade_id: "tradeId_example", user_id: "snaptrade-user-123", user_secret: "USERSECRET123", wait_to_confirm: true, ) p result ``` #### βš™οΈ Parameters ##### trade_id: `String` The ID of trade object obtained from trade/impact endpoint ##### user_id: `String` ##### user_secret: `String` ##### wait_to_confirm: `Boolean` 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 #### πŸ”„ Return [AccountOrderRecord](./lib/snaptrade/models/account_order_record.rb) #### 🌐 Endpoint `/trade/{tradeId}` `POST` [πŸ”™ **Back to Table of Contents**](#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 ```ruby result = 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", ) p result ``` #### βš™οΈ Parameters ##### user_id: `String` ##### user_secret: `String` ##### start_date: `Date` ##### end_date: `Date` ##### accounts: `String` Optional comma seperated list of account IDs used to filter the request on specific accounts ##### brokerage_authorizations: `String` Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations ##### type: `String` 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](./lib/snaptrade/models/universal_activity.rb) #### 🌐 Endpoint `/activities` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ### `snaptrade.transactions_and_reporting.get_reporting_custom_range` ![Deprecated](https://img.shields.io/badge/deprecated-yellow) 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 ```ruby result = 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", ) p result ``` #### βš™οΈ Parameters ##### start_date: `Date` ##### end_date: `Date` ##### user_id: `String` ##### user_secret: `String` ##### accounts: `String` Optional comma seperated list of account IDs used to filter the request on specific accounts ##### detailed: `Boolean` Optional, increases frequency of data points for the total value and contribution charts if set to true ##### frequency: `String` Optional frequency for the rate of return chart (defaults to monthly). Possible values are daily, weekly, monthly, quarterly, yearly. #### πŸ”„ Return [PerformanceCustom](./lib/snaptrade/models/performance_custom.rb) #### 🌐 Endpoint `/performance/custom` `GET` [πŸ”™ **Back to Table of Contents**](#table-of-contents) --- ## Author This TypeScript package is automatically generated by [Konfig](https://konfigthis.com)