Skip to content

Script add in for Google Sheets to pull in Charles Schwab account trading data in via their API

Notifications You must be signed in to change notification settings

bdf0506/schwab-googlesheets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

schwab-googlesheets

Script add in for Google Sheets to pull in Charles Schwab account trading data in via their API

Credits go to the following for laying the groundwork on the TD API to Google Sheets, which has been heavily modified to support the new Schwab API.

@santsleo https://github.com/santsleo/AmeritradeAPIonGoogleSheets

@kohjb https://github.com/kohjb/AmeritradeAPIwGoogleScripts

To use:

Set up the Schwab API:

  1. Sign up for a developer account from https://developer.schwab.com/register
  2. Create an app that uses the Trader API - Indidual, Account and Trading Production.
  3. Set the callback URL to https://127.0.0.1 and save.
  4. You'll need to wait until the app changes to "Ready for Use" before things will work - this can take some time, maybe a week or more.
  5. Grab the App Key and Secret from your app, as you will need this later.

In Google Sheets:

  1. Create a new sheet, and navigate to Tools > Script editor
  2. Add the 2 files from this repository into Files on the left side, and save.
  3. Go to Project Settings and navigate to the script properties section. Add a script property of "schwab_apikey" and enter your App Key from the Schwab app, and then add a script property of "schwab_secret" and enter your Secret from the Schwab app.
  4. Go to Schwab.gs, and click run. Google will make you approve this app to run.
  5. Exit script editor and back on the Google Sheet, you should now see a panel on the right side. If you don't see the right panel, go to Schwab API > Authenticate. Click on the link in the panel to login.
  6. Go through the login process to authorize this to connect to your Schwab account. You will be rerouted to a dead link, which is expected. Copy the URL that is now showing in the address bar.
  7. Paste the URL into Response text and then click the Step 2 button. The script will properly extract your code in the URL and get the needed refresh and access tokens.
  8. Now that your account is connected and you can start to call functions from the Google Sheet itself.

Functions available:

  • schwab_Positions
  • schwab_Balance
  • schwab_GetQuote

Easiest way to simply test that it is working, is to enter "=schwab_Positions()" into a single cell and press enter. Your current positions should now be shown in the Google Sheet.

Note:

Unlike the TD Ameritrade API where you only had to authenticate every 90 days, the Schwab API makes you authenticate every 7 days! Poor design of their API, but have not found any workaround to this yet.

About

Script add in for Google Sheets to pull in Charles Schwab account trading data in via their API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published