Giter Site home page Giter Site logo

tdameritrade-laravel's Introduction

Continuous Integration

TD Ameritrade API for Laravel

This package is a wrapper for the TD Ameritrade API. You will need a developer account to use this API.

Installing

1 . install the package via composer:

composer require mackensiealvarezz/tdameritrade-laravel

2. Publish Config

php artisan vendor:publish

3. Set ENV Variables

Include these two variables inside of your .env

// .env
TD_KEY="YOUR_KEY"
TD_CALLBACK="CALLBACK"

4. Include Package

When using the package, don't forget to include It on top of the file

use Mackensiealvarezz\Tdameritrade\Tdameritrade;

OAuth

To use the API, the must have an access_token. You can easily create an access token using the redirect function.

Creating OAuth URL

To create a OAuth URL, you will need to use:

 Tdameritrade::redirectOAuth(); // will return string (url)

It is important that you create a callback route for the URL you set inside of the .env

Refresh Token

To refresh the token and create another access_token.

//Create client 
$client =  new Tdameritrade('access_token', 'refresh_token');
//Refresh token
$response = $client->refreshToken();

Usage

The package is written to use every class inside of /src/api as a function.

Accounts

List accounts

This will return a list of all the accounts

//Create client
$client =  new Tdameritrade('access_token', 'refresh_token');
$accounts = $client->accounts()->list();

Get account

This will return all the information for one account. Requires account_id

//Create client
$client =  new Tdameritrade('access_token', 'refresh_token');
$accounts = $client->accounts()->get('account_id');

Instruments

Search

This will return a list of tickers based on the symbol entered

//Create client
$client =  new Tdameritrade('access_token', 'refresh_token');
//Response
$response = $client->instruments()->search('TESLA');

Get

This wil return one ticker information

//Create client
$client =  new Tdameritrade('access_token', 'refresh_token');
//Response
$accounts = $client->instruments()->get('TSLA');

Market Hours

List

This will return a list of all the different market hours

//Create client
$client =  new Tdameritrade('access_token', 'refresh_token');
//Response
$response = $client->market()->list();

Get

This wil return one market information

//Create client
$client =  new Tdameritrade('access_token', 'refresh_token');
//Response
$response = $client->market()->get('SPY.X');

Movers

Get

This wil return a list of symbols that are moving

//Create client
$client =  new Tdameritrade('access_token', 'refresh_token');
//Response
$response = $client->movers()->get('SPY.X', 'up', 'percent');

Price

History

This will return a list of quotes for the ticker

//Create client
$client =  new Tdameritrade('access_token', 'refresh_token');
//Response
$response = $client->price()->history('TSLA', Carbon::now(), Carbon::now());

Get Quote

This wil return the quote for one ticker

//Create client
$client =  new Tdameritrade('access_token', 'refresh_token');
//Response
$response = $client->price()->quote('TSLA');

Get Quotes

This wil return the quote for multiple tickers

//Create client
$client =  new Tdameritrade('access_token', 'refresh_token');
//Response
$response = $client->price()->quotes(['AAPL', 'FB']);

License

The MIT License (MIT). Please see MIT license for more information.

tdameritrade-laravel's People

Contributors

dependabot[bot] avatar ecomrick77 avatar johnpaulmedina avatar mackensiealvarezz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.