michaeldrennen/td-ameritrade-api
最新稳定版本:v0.2.3
Composer 安装命令:
composer require michaeldrennen/td-ameritrade-api
包简介
A PHP library used to interact with the TD Ameritrade API.
README 文档
README
A PHP library used to interact with the TD Ameritrade API
Visit the link below to set up your developer account with TD Ameritrade, and get information on how to authenticate with their API. https://developer.tdameritrade.com/
// How to create a TDAmeritrade API client. $userName = 'joeuser123'; $accessToken = 'stringFromTDAmeritradeAuthentication'; $refreshToken = 'anotherStringFromTDAmeritradeAuthentication'; $refreshTokenExpiresInSeconds = intFromTDAmeritradeAuthentication; $debug = false; $tdaClient = TDAmeritradeAPI( $userName, $accessToken, $refreshToken, $refreshTokenExpiresInSeconds, $debug );
// Once you have a client, you can buy stocks at market price. $accountId = 123456789; $ticker = 'LODE'; $quantity = 1; try { $tdaClient->buyStockSharesMarketPrice($accountId, $ticker, $quantity); } catch (Exception $exception) { echo $exception->getMessage(); } // Now, log into your TDAmeritrade account online, and you should see a new order. // To sell some shares at the market price... try { $tdaClient->sellStockSharesMarketPrice($accountId, $ticker, $quantity); } catch (Exception $exception) { echo $exception->getMessage(); }
You can look through the TDAmeritradeAPI.php file for a complete list of the actions I have written code for.
Happy trading!
-Mike
统计信息
- 总下载量: 478
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-11-15