Skip to main content

An easy and lightweight wrapper for using the Charles Schwab API.

Project description

Schwab-API-Python

PyPI - Version Discord PyPI - Downloads Donate YouTube Video Views
This package is not affiliated with or endorsed by Schwab, it is maintained by Tyler Bowers & Contributors.
It is licensed under the MIT license, and acts in accordance with Schwab's API terms and conditions.
Discord, PyPI, Youtube, Github.

Installation

pip install schwabdev
You may need to use pip3 instead of pip

Quick setup

  1. Setup your Schwab developer account here.
    • Create a new Schwab individual developer app with callback url "https://127.0.0.1"
    • Make a new app with both API products: "Accounts and Trading Production" and "Market Data Production".
    • Wait until the app status is "Ready for use", note that "Approved - Pending" will not work.
    • Enable TOS (Thinkorswim) for your Schwab account, it is needed for orders and other api calls.
  2. Install packages
    • Install schwabdev pip install schwabdev
    • You may need to use pip3 instead of pip
  3. Examples on how to use the client are in the examples/ folder (add your keys in the .env file)
    • The first time you run you will have to sign in to your Schwab account using the generated link in the terminal.
    • After signing in, agree to the terms, and select account(s). Then you will have to copy the link in the address bar and paste it into the terminal.
    • Questions? - join the Discord group or consult the /docs folder.
import schwabdev #import the package

client = schwabdev.Client('Your app key', 'Your app secret')  #create a client

print(client.account_linked().json()) #make api calls

What can this program do?

  • Authenticate and access the full api.
  • Automatic token management and "access token" refreshes.
  • Functions for all api functions (examples in examples/api_demo.py)
  • Stream real-time data with a customizable response handler (examples in examples/stream_demo.py)
  • Place orders and get order details (examples in examples/orders_demo.py)
  • Option for capture of callback urls when callback has a port (starts webserver on this port).
  • Option for automatic starting/stopping of streamer when market opens/closes.
  • Streaming stability with automatic restarts if the streamer crashes.

Notes

The schwabdev folder contains code for main operations:

  • __init__.py linker to client class.
  • client.py contains functions relating to api calls and requests.
  • tokens.py contains functions relating to token management.
  • stream.py contains functions for streaming data from websockets.

Youtube Tutorials

Github code has changed since these videos

  1. Authentication and Requests
  2. Streaming Real-time Data

MIT License

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

schwabdev-2.4.4.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

schwabdev-2.4.4-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file schwabdev-2.4.4.tar.gz.

File metadata

  • Download URL: schwabdev-2.4.4.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for schwabdev-2.4.4.tar.gz
Algorithm Hash digest
SHA256 ce65496398d973b3963b1df0aa70c2659fd997badc5176b1fdf43ded4a1ebadc
MD5 ac7f4f86f27a950be975b73280debe42
BLAKE2b-256 e2373c76804c295bd0c415faffc451e89aa47742ae9fedb4c0dc255467047123

See more details on using hashes here.

File details

Details for the file schwabdev-2.4.4-py3-none-any.whl.

File metadata

  • Download URL: schwabdev-2.4.4-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for schwabdev-2.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 47737e3a733bfe008d9cda552304dcfd3e942f368b04ece899891a895e48125c
MD5 64b3cbe75c32d2677103f8abaa6575ca
BLAKE2b-256 525c71e2b869ac1a7df1d9f37672fa89489d6eca607b3defe64c680e1e62efc4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page