Skip to main content

This is an unofficial interface to make using the Schwab API easier.

Project description

Pythonic-Schwab-API

This is an unofficial Python wrapper for accessing the individual Schwab API, designed for developers who require a straightforward and efficient method to interact with financial data and trading operations.

You will need a Schwab developer account before you can use this wrapper.

For community support and discussions, join our Pythonic Schwab API Discord group.

Quick Setup

  1. Create a Schwab Developer App: Register a new application with a callback URL set to "https://127.0.0.1". Ensure the app status changes to "Ready for use", as "Approved - Pending" status means it has not yet been approved.
  2. Enable Thinkorswim (TOS): This is necessary for order placements and other critical API functionalities.
  3. Install Python: This wrapper requires Python version 3.11 or higher.
  4. Install Dependencies: Run pip install -r requirements.txt.
  5. Configure Environment: Populate your .env file with your APP_KEY and APP_SECRET.
  6. Run the Program: Start by executing main.py.

Capabilities

  • API Authentication: Utilizes OAuth for secure access schwab-api.initialize().
  • Comprehensive API Function Coverage: Includes ready-to-use functions for all API endpoints schwab-api.perform_request().
  • Automatic Token Management: Handles access token renewals schwab-api.update_tokens_automatically().
  • Real-Time Data Streaming: Facilitates streaming via websockets schwab-api.stream.start_manual().
  • Automated Stream Management: Automates the start and stop of data streams schwab-api.stream.start_automatically().

Additional Features (TBD)

  • Refresh Token Automation: Pending Schwab's API enhancements.
  • Custom Stream Handlers: Pending implementation for user-defined data handling.

Usage and Design

This Python client simplifies interactions with the Schwab API by providing a user-friendly, organized, and automated interface. The design focuses on clear structure and maintainability.

Project Structure

  • main.py: Serves as the entry point of the application, and includes usage examples.
  • .env: Stores sensitive credentials like the API key and secret.
  • tokens.json: Maintains API tokens and their expiration metadata.

Modules

  • schwab-api.py: Manages API interactions, token lifecycle, and request handling.
  • stream.py: Handles web socket connections for live data feeds.
  • terminal.py: Enhances terminal output with color-coded messages and supports additional terminal operations.

Special Thanks

Credit to Tyler Bowers for inspiring this work. This started as a blatant rip-off of his work formatted in a more pythonic way. We started as a fork but felt this would likely end up going in a whole different direction as far as our intended purpose and scope. Thank you, Tyler, for your work. We will continue to steal his work and publish it as our own and hope he does the same if it is ever advantageous for him to return the favor.

License (MIT)

Pythonic-Schwab-API is an unofficial API wrapper. It is in no way endorsed by or affiliated with Charles Schwab or any associated organization. Make sure to read and understand the terms of service of the underlying API before using this package. This 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 non-infringement. In no event shall the authors or copyright holders be responsible for any claim, damages, or other liabilities, 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

pythonic_schwab_api-0.3.0.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

pythonic_schwab_api-0.3.0-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file pythonic_schwab_api-0.3.0.tar.gz.

File metadata

  • Download URL: pythonic_schwab_api-0.3.0.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for pythonic_schwab_api-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e2b9a3723d77096daf7b23546de39e277b5b01605eb92a9deca0fc58469122e5
MD5 c4c7456c27108acaf571c8ffc2011ed9
BLAKE2b-256 99d43ed916cbb55f9607b0130c245b4e0bcdaf3318d53937f3fdbd4acdfc2fd2

See more details on using hashes here.

File details

Details for the file pythonic_schwab_api-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pythonic_schwab_api-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85282c4febd8918dc9dc6eab471720a6da4ce69b48f792e4b47f3d3ed26f9d6c
MD5 6150c0f8293dc1e8ccda7eaa19d5430c
BLAKE2b-256 7291fa18de9d090129a314326ac6d1fb0d00f0ebc0a11fc8895e29891b3be29a

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