PHP code example of konfig / snaptrade-php-7-sdk
1. Go to this page and download the library: Download konfig/snaptrade-php-7-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
konfig / snaptrade-php-7-sdk example snippets
ptrade = new \SnapTrade\Client(
getenv("SNAPTRADE_CONSUMER_KEY"),
getenv("SNAPTRADE_CLIENT_ID")
);
$result = $snaptrade->accountInformation->getAllUserHoldings(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631"
);
$result = $snaptrade->accountInformation->getAllUserHoldings(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631"
);
$result = $snaptrade->accountInformation->getUserAccountBalance(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631"
);
$result = $snaptrade->accountInformation->getUserAccountDetails(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631"
);
$result = $snaptrade->accountInformation->getUserAccountOrders(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631",
"all",
30
);
$result = $snaptrade->accountInformation->getUserAccountPositions(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631"
);
$result = $snaptrade->accountInformation->getUserAccountRecentOrders(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631",
True
);
$result = $snaptrade->accountInformation->getUserAccountReturnRates(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631"
);
$result = $snaptrade->accountInformation->getUserHoldings(
"917c8734-8470-4a3e-a18f-57c3f2ee6631",
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61"
);
$result = $snaptrade->accountInformation->listUserAccounts(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61"
);
$result = $snaptrade->accountInformation->updateUserAccount(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"accountId_example"
);
$result = $snaptrade->apiStatus->check();
$result = $snaptrade->authentication->deleteSnapTradeUser(
"snaptrade-user-123"
);
$result = $snaptrade->authentication->listSnapTradeUsers();
$result = $snaptrade->authentication->loginSnapTradeUser(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"ALPACA",
True,
"https://snaptrade.com",
"8b5f262d-4bb9-365d-888a-202bd3b15fa1",
"read",
"v4"
);
$result = $snaptrade->authentication->registerSnapTradeUser(
"snaptrade-user-123"
);
$result = $snaptrade->authentication->resetSnapTradeUserSecret(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61"
);
$result = $snaptrade->connections->detailBrokerageAuthorization(
"87b24961-b51e-4db8-9226-f198f6518a89",
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61"
);
$result = $snaptrade->connections->disableBrokerageAuthorization(
"87b24961-b51e-4db8-9226-f198f6518a89",
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61"
);
$result = $snaptrade->connections->listBrokerageAuthorizations(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61"
);
$result = $snaptrade->connections->refreshBrokerageAuthorization(
"87b24961-b51e-4db8-9226-f198f6518a89",
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61"
);
$snaptrade->connections->removeBrokerageAuthorization(
"87b24961-b51e-4db8-9226-f198f6518a89",
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61"
);
$result = $snaptrade->connections->returnRates(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"87b24961-b51e-4db8-9226-f198f6518a89"
);
$result = $snaptrade->connections->sessionEvents(
"SNAPTRADETEST",
"917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
"917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2"
);
$result = $snaptrade->options->getOptionStrategy(
"2bcd7cc3-e922-4976-bce1-9858296801c3",
[
[
"action" => "BUY_TO_OPEN",
"option_symbol_id" => "SPY220819P00200000",
"quantity" => 1,
]
],
"CUSTOM",
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"accountId_example"
);
$result = $snaptrade->options->getOptionsChain(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"accountId_example",
"symbol_example"
);
$result = $snaptrade->options->getOptionsStrategyQuote(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"accountId_example",
"2bcd7cc3-e922-4976-bce1-9858296801c3"
);
$result = $snaptrade->options->listOptionHoldings(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631"
);
$result = $snaptrade->options->placeOptionStrategy(
"Market",
"FOK",
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"2bcd7cc3-e922-4976-bce1-9858296801c3",
"2bcd7cc3-e922-4976-bce1-9858296801c3",
31.33
);
$result = $snaptrade->referenceData->getCurrencyExchangeRatePair(
"currencyPair_example"
);
$result = $snaptrade->referenceData->getPartnerInfo();
$result = $snaptrade->referenceData->getSecurityTypes();
$result = $snaptrade->referenceData->getStockExchanges();
$result = $snaptrade->referenceData->getSymbols(
"AAPL"
);
$result = $snaptrade->referenceData->getSymbolsByTicker(
"query_example"
);
$result = $snaptrade->referenceData->listAllBrokerageAuthorizationType(
"QUESTRADE,ALPACA"
);
$result = $snaptrade->referenceData->listAllBrokerages();
$result = $snaptrade->referenceData->listAllCurrencies();
$result = $snaptrade->referenceData->listAllCurrenciesRates();
$result = $snaptrade->referenceData->symbolSearchUserAccount(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631",
"AAPL"
);
$result = $snaptrade->trading->cancelUserAccountOrder(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631",
"66a033fa-da74-4fcf-b527-feefdec9257e"
);
$result = $snaptrade->trading->getOrderImpact(
"917c8734-8470-4a3e-a18f-57c3f2ee6631",
"BUY",
"2bcd7cc3-e922-4976-bce1-9858296801c3",
"Market",
"FOK",
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
31.33,
31.33,
10.5,
None
);
$result = $snaptrade->trading->getUserAccountQuotes(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"symbols_example",
"917c8734-8470-4a3e-a18f-57c3f2ee6631",
True
);
$result = $snaptrade->trading->placeForceOrder(
"917c8734-8470-4a3e-a18f-57c3f2ee6631",
"BUY",
"Market",
"FOK",
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"2bcd7cc3-e922-4976-bce1-9858296801c3",
"AAPL 131124C00240000",
31.33,
31.33,
10.5,
None
);
$result = $snaptrade->trading->placeOrder(
"139e307a-82f7-4402-b39e-4da7baa87758",
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
True
);
$result = $snaptrade->transactionsAndReporting->getActivities(
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"2022-01-24",
"2022-01-24",
"917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
"917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
"BUY,SELL,DIVIDEND"
);
$result = $snaptrade->transactionsAndReporting->getReportingCustomRange(
"2022-01-24",
"2022-01-24",
"snaptrade-user-123",
"adf2aa34-8219-40f7-a6b3-60156985cc61",
"917c8734-8470-4a3e-a18f-57c3f2ee6631,65e839a3-9103-4cfb-9b72-2071ef80c5f2",
True,
"monthly"
);
json
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/passiv/snaptrade-php-7-sdk.git"
}
],
"