konfig/snaptrade-php-sdk

Connect brokerage accounts to your app for live positions and trading


README

Visit SnapTrade

SnapTrade

Connect brokerage accounts to your app for live positions and trading

Packagist More Info

Table of Contents

Installation & Usage

Requirements

This library requires PHP ^8.0

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/passiv/snaptrade-php-sdk.git"
    }
  ],
  "require": {
    "konfig/snaptrade-php-sdk": "2.0.22"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

<?php
require_once('/path/to/snaptrade-php-sdk/vendor/autoload.php');

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

$snaptrade = new \SnapTrade\Client(
    clientId: getenv("SNAPTRADE_CLIENT_ID"),
    consumerKey: getenv("SNAPTRADE_CONSUMER_KEY")
);

$result = $snaptrade->accountInformation->getAllUserHoldings(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631"
);

Reference

snaptrade.accountInformation.getAllUserHoldings

Deprecated

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

πŸ› οΈ Usage

$result = $snaptrade->accountInformation->getAllUserHoldings(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631"
);

βš™οΈ 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

🌐 Endpoint

/holdings GET

πŸ”™ Back to Table of Contents

snaptrade.accountInformation.getUserAccountBalance

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

πŸ› οΈ Usage

$result = $snaptrade->accountInformation->getUserAccountBalance(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631"
);

βš™οΈ Parameters

user_id: string
user_secret: string
account_id: string

The ID of the account to get balances.

πŸ”„ Return

Balance

🌐 Endpoint

/accounts/{accountId}/balances GET

πŸ”™ Back to Table of Contents

snaptrade.accountInformation.getUserAccountDetails

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

πŸ› οΈ Usage

$result = $snaptrade->accountInformation->getUserAccountDetails(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631"
);

βš™οΈ Parameters

user_id: string
user_secret: string
account_id: string

The ID of the account to get detail of.

πŸ”„ Return

Account

🌐 Endpoint

/accounts/{accountId} GET

πŸ”™ Back to Table of Contents

snaptrade.accountInformation.getUserAccountOrders

Fetch all recent orders from a user's account.

πŸ› οΈ Usage

$result = $snaptrade->accountInformation->getUserAccountOrders(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", 
    state: "all", 
    days: 30
);

βš™οΈ Parameters

user_id: string
user_secret: string
account_id: string

The ID of the account to get orders.

state: string

defaults value is set to "all"

days: int

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

πŸ”„ Return

AccountOrderRecord

🌐 Endpoint

/accounts/{accountId}/orders GET

πŸ”™ Back to Table of Contents

snaptrade.accountInformation.getUserAccountPositions

Returns a list of positions in the specified account.

πŸ› οΈ Usage

$result = $snaptrade->accountInformation->getUserAccountPositions(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631"
);

βš™οΈ Parameters

user_id: string
user_secret: string
account_id: string

The ID of the account to get positions.

πŸ”„ Return

Position

🌐 Endpoint

/accounts/{accountId}/positions GET

πŸ”™ Back to Table of Contents

snaptrade.accountInformation.getUserHoldings

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

πŸ› οΈ Usage

$result = $snaptrade->accountInformation->getUserHoldings(
    account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", 
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123"
);

βš™οΈ Parameters

account_id: string

The ID of the account to fetch holdings for.

user_id: string
user_secret: string

πŸ”„ Return

AccountHoldingsAccount

🌐 Endpoint

/accounts/{accountId}/holdings GET

πŸ”™ Back to Table of Contents

snaptrade.accountInformation.listUserAccounts

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

πŸ› οΈ Usage

$result = $snaptrade->accountInformation->listUserAccounts(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123"
);

βš™οΈ Parameters

user_id: string
user_secret: string

πŸ”„ Return

Account

🌐 Endpoint

/accounts GET

πŸ”™ Back to Table of Contents

snaptrade.accountInformation.updateUserAccount

Updates various properties of a specified account.

πŸ› οΈ Usage

$result = $snaptrade->accountInformation->updateUserAccount(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "accountId_example"
);

βš™οΈ Parameters

user_id: string
user_secret: string
account_id: string

The ID of the account to update.

πŸ”„ Return

Account

🌐 Endpoint

/accounts/{accountId} PUT

πŸ”™ Back to Table of Contents

snaptrade.apiStatus.check

Check whether the API is operational and verify timestamps.

πŸ› οΈ Usage

$result = $snaptrade->apiStatus->check();

πŸ”„ Return

Status

🌐 Endpoint

/ GET

πŸ”™ Back to Table of Contents

snaptrade.authentication.deleteSnapTradeUser

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

πŸ› οΈ Usage

$result = $snaptrade->authentication->deleteSnapTradeUser(
    user_id: "snaptrade-user-123"
);

βš™οΈ Parameters

user_id: string

πŸ”„ Return

DeleteUserResponse

🌐 Endpoint

/snapTrade/deleteUser DELETE

πŸ”™ Back to Table of Contents

snaptrade.authentication.getUserJWT

This API is available to ClientIDs which have opted to use encrypted JWTs (JSON Web Tokens) instead of standard SnapTrade signature verification.

πŸ› οΈ Usage

$result = $snaptrade->authentication->getUserJWT(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123"
);

βš™οΈ Parameters

user_id: string
user_secret: string

πŸ”„ Return

EncryptedResponse

🌐 Endpoint

/snapTrade/encryptedJWT GET

πŸ”™ Back to Table of Contents

snaptrade.authentication.listSnapTradeUsers

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

πŸ› οΈ Usage

$result = $snaptrade->authentication->listSnapTradeUsers();

πŸ”„ Return

string[]

🌐 Endpoint

/snapTrade/listUsers GET

πŸ”™ Back to Table of Contents

snaptrade.authentication.loginSnapTradeUser

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

πŸ› οΈ Usage

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

βš™οΈ Parameters

user_id: string
user_secret: string
broker: string

Slug of the brokerage to connect the user to

immediateRedirect: bool

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: string

Sets whether the connection should be read or trade

connectionPortalVersion: string

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

πŸ”„ Return

AuthenticationLoginSnapTradeUser200Response

🌐 Endpoint

/snapTrade/login POST

πŸ”™ Back to Table of Contents

snaptrade.authentication.registerSnapTradeUser

Registers a new SnapTrade user under your ClientID. Most SnapTrade operations require a user to be passed as a parameter.

πŸ› οΈ Usage

$result = $snaptrade->authentication->registerSnapTradeUser(
    user_id: "snaptrade-user-123"
);

βš™οΈ 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

🌐 Endpoint

/snapTrade/registerUser POST

πŸ”™ Back to Table of Contents

snaptrade.authentication.resetSnapTradeUserSecret

This API is used to generate a new secret for a SnapTrade user. You might use this if a userSecret is comprimised or lost among other reasons.

πŸ› οΈ Usage

$result = $snaptrade->authentication->resetSnapTradeUserSecret(
    user_id: "snaptrade-user-123", 
    user_secret: "h81@cx1lkalablakwjaltkejraj11="
);

βš™οΈ 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 should be considered priviledged information and if compromised, you should delete and re-create this SnapTrade user.

πŸ”„ Return

UserIDandSecret

🌐 Endpoint

/snapTrade/resetUserSecret POST

πŸ”™ Back to Table of Contents

snaptrade.connections.detailBrokerageAuthorization

Returns a single brokerage authorization object for the specified ID.

πŸ› οΈ Usage

$result = $snaptrade->connections->detailBrokerageAuthorization(
    authorization_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", 
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123"
);

βš™οΈ Parameters

authorization_id: string

The ID of a brokerage authorization object.

user_id: string
user_secret: string

πŸ”„ Return

BrokerageAuthorization

🌐 Endpoint

/authorizations/{authorizationId} GET

πŸ”™ Back to Table of Contents

snaptrade.connections.listBrokerageAuthorizations

Returns a list of Brokerage Authorization objects for the user

πŸ› οΈ Usage

$result = $snaptrade->connections->listBrokerageAuthorizations(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123"
);

βš™οΈ Parameters

user_id: string
user_secret: string

πŸ”„ Return

BrokerageAuthorization

🌐 Endpoint

/authorizations GET

πŸ”™ Back to Table of Contents

snaptrade.connections.refreshBrokerageAuthorization

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

πŸ› οΈ Usage

$result = $snaptrade->connections->refreshBrokerageAuthorization(
    authorization_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", 
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123"
);

βš™οΈ Parameters

authorization_id: string

The ID of a brokerage authorization object.

user_id: string
user_secret: string

πŸ”„ Return

BrokerageAuthorizationRefreshConfirmation

🌐 Endpoint

/authorizations/{authorizationId}/refresh POST

πŸ”™ Back to Table of Contents

snaptrade.connections.removeBrokerageAuthorization

Deletes a specified brokerage authorization given by the ID.

πŸ› οΈ Usage

$snaptrade->connections->removeBrokerageAuthorization(
    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

πŸ”„ Return

void (empty response body)

🌐 Endpoint

/authorizations/{authorizationId} DELETE

πŸ”™ Back to Table of Contents

snaptrade.connections.sessionEvents

Returns a list of session events associated with a user.

πŸ› οΈ Usage

$result = $snaptrade->connections->sessionEvents(
    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: 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

🌐 Endpoint

/sessionEvents GET

πŸ”™ Back to Table of Contents

snaptrade.options.getOptionStrategy

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

πŸ› οΈ Usage

$result = $snaptrade->options->getOptionStrategy(
    underlying_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", 
    legs: [
        [
            "action" => "BUY_TO_OPEN",
            "option_symbol_id" => "SPY220819P00200000",
            "quantity" => 1,
        ]
    ], 
    strategy_type: "CUSTOM", 
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "accountId_example"
);

βš™οΈ Parameters

underlying_symbol_id: string
legs: OptionLeg[]
strategy_type: string
user_id: string
user_secret: string
account_id: string

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

πŸ”„ Return

StrategyQuotes

🌐 Endpoint

/accounts/{accountId}/optionStrategy POST

πŸ”™ Back to Table of Contents

snaptrade.options.getOptionsChain

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

πŸ› οΈ Usage

$result = $snaptrade->options->getOptionsChain(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "accountId_example", 
    symbol: "symbol_example"
);

βš™οΈ 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

🌐 Endpoint

/accounts/{accountId}/optionsChain GET

πŸ”™ Back to Table of Contents

snaptrade.options.getOptionsStrategyQuote

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

πŸ› οΈ Usage

$result = $snaptrade->options->getOptionsStrategyQuote(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "accountId_example", 
    option_strategy_id: "2bcd7cc3-e922-4976-bce1-9858296801c3"
);

βš™οΈ 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

🌐 Endpoint

/accounts/{accountId}/optionStrategy/{optionStrategyId} GET

πŸ”™ Back to Table of Contents

snaptrade.options.listOptionHoldings

Returns a list of Options Positions.

πŸ› οΈ Usage

$result = $snaptrade->options->listOptionHoldings(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "accountId_example"
);

βš™οΈ Parameters

user_id: string
user_secret: string
account_id: string

The ID of the account to fetch options holdings for.

πŸ”„ Return

OptionsPosition

🌐 Endpoint

/accounts/{accountId}/options GET

πŸ”™ Back to Table of Contents

snaptrade.options.placeOptionStrategy

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

πŸ› οΈ Usage

$result = $snaptrade->options->placeOptionStrategy(
    order_type: "Limit", 
    time_in_force: "FOK", 
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", 
    option_strategy_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", 
    price: 31.33
);

βš™οΈ Parameters

order_type:
time_in_force:
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

🌐 Endpoint

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

πŸ”™ Back to Table of Contents

snaptrade.referenceData.getCurrencyExchangeRatePair

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

πŸ› οΈ Usage

$result = $snaptrade->referenceData->getCurrencyExchangeRatePair(
    currency_pair: "currencyPair_example"
);

βš™οΈ Parameters

currency_pair: string

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

πŸ”„ Return

ExchangeRatePairs

🌐 Endpoint

/currencies/rates/{currencyPair} GET

πŸ”™ Back to Table of Contents

snaptrade.referenceData.getPartnerInfo

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

πŸ› οΈ Usage

$result = $snaptrade->referenceData->getPartnerInfo();

πŸ”„ Return

PartnerData

🌐 Endpoint

/snapTrade/partners GET

πŸ”™ Back to Table of Contents

snaptrade.referenceData.getSecurityTypes

List security types available on SnapTrade.

πŸ› οΈ Usage

$result = $snaptrade->referenceData->getSecurityTypes();

πŸ”„ Return

SecurityType

🌐 Endpoint

/securityTypes GET

πŸ”™ Back to Table of Contents

snaptrade.referenceData.getStockExchanges

Returns a list of all supported Exchanges.

πŸ› οΈ Usage

$result = $snaptrade->referenceData->getStockExchanges();

πŸ”„ Return

Exchange

🌐 Endpoint

/exchanges GET

πŸ”™ Back to Table of Contents

snaptrade.referenceData.getSymbols

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

Matches on ticker or name.

πŸ› οΈ Usage

$result = $snaptrade->referenceData->getSymbols(
    substring: "apple"
);

βš™οΈ Parameters

substring: string

πŸ”„ Return

UniversalSymbol

🌐 Endpoint

/symbols POST

πŸ”™ Back to Table of Contents

snaptrade.referenceData.getSymbolsByTicker

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

πŸ› οΈ Usage

$result = $snaptrade->referenceData->getSymbolsByTicker(
    query: "query_example"
);

βš™οΈ Parameters

query: string

The ticker or universal_symbol_id of the UniversalSymbol to get.

πŸ”„ Return

UniversalSymbol

🌐 Endpoint

/symbols/{query} GET

πŸ”™ Back to Table of Contents

snaptrade.referenceData.listAllBrokerageAuthorizationType

Returns a list of all defined Brokerage authorization Type objects.

πŸ› οΈ Usage

$result = $snaptrade->referenceData->listAllBrokerageAuthorizationType(
    brokerage: "QUESTRADE,ALPACA"
);

βš™οΈ Parameters

brokerage: string

Comma separated value of brokerage slugs

πŸ”„ Return

BrokerageAuthorizationTypeReadOnly

🌐 Endpoint

/brokerageAuthorizationTypes GET

πŸ”™ Back to Table of Contents

snaptrade.referenceData.listAllBrokerages

Returns a list of all defined Brokerage objects.

πŸ› οΈ Usage

$result = $snaptrade->referenceData->listAllBrokerages();

πŸ”„ Return

Brokerage

🌐 Endpoint

/brokerages GET

πŸ”™ Back to Table of Contents

snaptrade.referenceData.listAllCurrencies

Returns a list of all defined Currency objects.

πŸ› οΈ Usage

$result = $snaptrade->referenceData->listAllCurrencies();

πŸ”„ Return

Currency

🌐 Endpoint

/currencies GET

πŸ”™ Back to Table of Contents

snaptrade.referenceData.listAllCurrenciesRates

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

πŸ› οΈ Usage

$result = $snaptrade->referenceData->listAllCurrenciesRates();

πŸ”„ Return

ExchangeRatePairs

🌐 Endpoint

/currencies/rates GET

πŸ”™ Back to Table of Contents

snaptrade.referenceData.symbolSearchUserAccount

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

$result = $snaptrade->referenceData->symbolSearchUserAccount(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", 
    substring: "apple"
);

βš™οΈ Parameters

user_id: string
user_secret: string
account_id: string

The ID of the account to search for symbols within.

substring: string

πŸ”„ Return

UniversalSymbol

🌐 Endpoint

/accounts/{accountId}/symbols POST

πŸ”™ Back to Table of Contents

snaptrade.trading.cancelUserAccountOrder

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

πŸ› οΈ Usage

$result = $snaptrade->trading->cancelUserAccountOrder(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", 
    brokerage_order_id: "2bcd7cc3-e922-4976-bce1-9858296801c3"
);

βš™οΈ Parameters

user_id: string
user_secret: string
account_id: string

The ID of the account to cancel the order in.

brokerage_order_id: string

πŸ”„ Return

AccountOrderRecord

🌐 Endpoint

/accounts/{accountId}/orders/cancel POST

πŸ”™ Back to Table of Contents

snaptrade.trading.getOrderImpact

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

πŸ› οΈ Usage

$result = $snaptrade->trading->getOrderImpact(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", 
    action: "BUY", 
    order_type: "Limit", 
    price: 31.33, 
    stop: 31.33, 
    time_in_force: "FOK", 
    units: 3.14, 
    universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", 
    notional_value: None
);

βš™οΈ Parameters

user_id: string
user_secret: string
account_id: string
action:
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:
units: float
universal_symbol_id: string
notional_value: ManualTradeFormNotionalValue

πŸ”„ Return

ManualTradeAndImpact

🌐 Endpoint

/trade/impact POST

πŸ”™ Back to Table of Contents

snaptrade.trading.getUserAccountQuotes

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

πŸ› οΈ Usage

$result = $snaptrade->trading->getUserAccountQuotes(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    symbols: "symbols_example", 
    account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631", 
    use_ticker: True
);

βš™οΈ 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: bool

Should be set to True if providing tickers.

πŸ”„ Return

SymbolsQuotesInner

🌐 Endpoint

/accounts/{accountId}/quotes GET

πŸ”™ Back to Table of Contents

snaptrade.trading.placeForceOrder

Places a specified trade in the specified account.

πŸ› οΈ Usage

$result = $snaptrade->trading->placeForceOrder(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", 
    action: "BUY", 
    order_type: "Limit", 
    price: 31.33, 
    stop: 31.33, 
    time_in_force: "FOK", 
    units: 3.14, 
    universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3", 
    notional_value: None
);

βš™οΈ Parameters

user_id: string
user_secret: string
account_id: string
action:
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:
units: float
universal_symbol_id: string
notional_value: ManualTradeFormNotionalValue

πŸ”„ Return

AccountOrderRecord

🌐 Endpoint

/trade/place POST

πŸ”™ Back to Table of Contents

snaptrade.trading.placeOrder

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

πŸ› οΈ Usage

$result = $snaptrade->trading->placeOrder(
    trade_id: "tradeId_example", 
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    wait_to_confirm: True
);

βš™οΈ Parameters

trade_id: string

The ID of trade object obtained from trade/impact endpoint

user_id: string
user_secret: string
wait_to_confirm: 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

πŸ”„ Return

AccountOrderRecord

🌐 Endpoint

/trade/{tradeId} POST

πŸ”™ Back to Table of Contents

snaptrade.transactionsAndReporting.getActivities

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

πŸ› οΈ Usage

$result = $snaptrade->transactionsAndReporting->getActivities(
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    start_date: "2022-01-24", 
    end_date: "2022-01-24", 
    accounts: "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2", 
    brokerage_authorizations: "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2", 
    type: "DIVIDEND"
);

βš™οΈ Parameters

user_id: string
user_secret: string
start_date: \DateTime
end_date: \DateTime
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

🌐 Endpoint

/activities GET

πŸ”™ Back to Table of Contents

snaptrade.transactionsAndReporting.getReportingCustomRange

Deprecated

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

πŸ› οΈ Usage

$result = $snaptrade->transactionsAndReporting->getReportingCustomRange(
    start_date: "2022-01-24", 
    end_date: "2022-01-24", 
    user_id: "snaptrade-user-123", 
    user_secret: "USERSECRET123", 
    accounts: "917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2", 
    detailed: True, 
    frequency: "monthly"
);

βš™οΈ Parameters

start_date: \DateTime
end_date: \DateTime
user_id: string
user_secret: string
accounts: string

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: string

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

πŸ”„ Return

PerformanceCustom

🌐 Endpoint

/performance/custom GET

πŸ”™ Back to Table of Contents

Author

This PHP package is automatically generated by Konfig