@pyriter/schwab-client
v0.4.1
Published
Schwab Client
Downloads
123
Readme
Charles Schwab Client for Nodejs
Overview
A Javascript client for the Charles Schwab Restful API written in Typescript for NodeJs.
Features
- Auto fetch refresh token when access token expires.
- Credentials can be fetched and stored using these providers
- Local cache
- Local file
- Customizable (e.g. connect to datastore such as S3 or DynamoDB)
- Get user account information
- Get watchlist
- Get option chain
- Get quote
- Manage orders
- Get transactions
- Get market hours
- Get price history
- Place/Replace order
Install
$ npm install @pyriter/schwab-client
Getting an Access Token
To gain access to the Schwab (TDA) APIs, you will need to get an access token from your trading account.
How to use it
Instantiate the SchwabClient object
At the bare minimum, you will need to provide an access token and client id and client secret in order to instantiate the schwabClient.
Development setup for running tests
- Create a credentials.json file at the package root level with the following information:
{
"client_id": "",
"client_secret": "",
"redirect_uri": "http://localhost/"
}
- Run the script to generate the login url
node ./generateAuthUrl.js
- Open the url provided from the output of step #2 in a browser and login to Schwab.
- After logging in and agreeing to the terms. You will then get to a redirect to
localhost
with the code as part of the query params. Copy this url link in its entirety. - Within the terminal run the script to generate the auth token
node ./extractAuthCode.js [paste-your-url-from-step-4-here]
- Run the tests
npm tests
Publishing to npm
This command will update the package version and then publish to the public npm repo
$ npm version [patch | minor major]
$ npm publish
Appendix
License
Schwab Client is MIT licensed.