AlertKeeper 0.2.12

Connect Schwab

AlertKeeper reads your Schwab accounts through Schwab's own API, with an app key of your own: once a day it brings in your positions and balances, the transactions since the last read, and the greeks of your open options. It never trades. Your broker files keep working as before -- a row both carry is counted once, matched by what it means: Schwab's API lists each fill of an order where the file shows the order, dates an expiry the day it was posted, and moves cash to and from its bank sweep, which the files never show. The app key must be yours alone: Schwab keeps one sign-in per app key and login, so another program signing in with the same key ends AlertKeeper's sign-in (and the other way round).

Steps

  1. If another program on this computer already signs in to Schwab with the app key you mean to use, don't sign in twice -- AlertKeeper's sign-in would end that program's. Set that program to use AlertKeeper's sign-in instead (Sharing the sign-in with your own programs, below), and only then Connect here.
  2. On developer.schwab.com, sign up for a developer account with your Schwab login. Schwab looks at new developer accounts before they can make apps; that can take a few days.
  3. Make one app, just for AlertKeeper (the product Accounts and Trading Production). For its callback, copy the address Settings → Broker shows -- this computer (127.0.0.1), port 8080, /callback -- exactly; choose another port there first if 8080 is taken on your computer. Schwab reviews new apps: wait until it says Ready For Use.
  4. Your app's page there shows its App key and Secret. In AlertKeeper: Settings → Broker, type both and the callback port, and press Connect. Both go into your Keychain (Mac) or Credential Manager (Windows), never into a file.
  5. Schwab's sign-in opens in your browser: sign in, allow access, and choose the accounts AlertKeeper may read.
  6. The browser then warns that 127.0.0.1's connection isn't private: that's AlertKeeper on your own computer, catching Schwab's answer. Choose to go on (Advanced → Proceed). If the browser won't, copy the whole address from its address bar into Or paste the address on Settings → Broker.
  7. Press Read now on Settings → Broker for the first read (two years of transactions, a minute or two); after that it happens by itself once a day, and the button says when: Read at 2:17 PM.

What you should see

If it doesn't work

Sharing the sign-in with your own programs

Most people never need this. It's for someone who also runs a program of their own that reads Schwab with the same app key: rather than signing in itself -- which would end AlertKeeper's sign-in -- that program can use AlertKeeper's.

The sign-in's state, always: AlertKeeper keeps a small file other programs on this computer may read, broker/schwab-status.json in AlertKeeper's data folder (~/Library/Application Support/AlertKeeper on a Mac, %LOCALAPPDATA%\AlertKeeper on Windows): when the current access token runs out (expires_at), when it was last refreshed (last_refresh_at) and, if Schwab refused a refresh, its code, words and time (refusal) -- times in seconds since 1970. No token is ever in it.

The token itself, only when you say: on Settings → Broker, Share the sign-in with other programs on this Mac (off until you turn it on). AlertKeeper then writes broker/schwab-share.json, which only you can read, with the address to ask and the key. Your program sends a GET to that address with the header Authorization: Bearer and the key, and gets back access_token and expires_at (seconds since 1970); AlertKeeper keeps the token fresh, so it answers at once. A wrong key gets 401 -- read the file again, AlertKeeper may have started since; with sharing off, or no sign-in, 503. Never the refresh token, the app key or the secret; only from this computer; a new key each time AlertKeeper starts; nothing at all while the switch is off. The Broker page says it's on, and when the sign-in was last given.

Good to know