Unofficial Schwab API wrapper in Python 3.
Project description
Schwab API
This is not an official API or even a stable recreation of a Charles Schwab API. Functionality may change with any updates made by Schwab.
This package enables buying and selling securities programmatically on Charles Schwab using Playwright. Essentially, this package uses headless Chromium to automate the clicks and inputs; it does NOT use web requests (though I'd love to change the code to do so).
Getting Started
Installing
I plan to publish this to pypi soon. Until then, you're going to want to clone the repo and install like so:
git clone https://github.com/itsjafer/schwab-python.git
cd schwab-python
pip install .
python -m playwright install
Quickstart
Here's some code that logs in and makes a stock purchase:
from schwab_api import Schwab
# Initialize our schwab instance
# We can only have one instance running at a time
api = Schwab.get_instance(
username=username,
password=password,
user_agent=user_agent
)
# Login
# First-time setup: you will need to enter an SMS confirmation code as input
api.login(screenshot=True)
# Make a trade
api.trade(
ticker="ticker",
side="Buy" ## or "Sell",
qty=1,
screenshot=False # for debugging turn this on
)
Documentation
There is currently no documentation. If there is traction or demand, I will slowly add this in.
Features
- Buying and Selling tickers
- Multiple individual account support
- Persistent authentication (after an initial MFA setup)
- Headless playwright implementation
Todo
- Export an actual function for modular use
- Get this setup on a VM or a cloud function
- Randomize and humanize every click and input interaction
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for schwab_api-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04309f2a7087085703954bebcb7ebfa2af2ce7fb695f25cdd7f78366dff16f84 |
|
MD5 | 9839df02fd9a8daa8b421349063a8784 |
|
BLAKE2b-256 | 5241e2efdd9c65a66c4736a6b8ed9d39cf71c47a9569099da5333f7dd98f11d8 |