No project description provided
Project description
(Unofficial) Charles Schwab Stock and Option Trade API Client
Overview
This is a Python client library for accessing the Charles Schwab stock and option trade API. It provides a convenient way to interact with the Charles Schwab trading platform programmatically.
Features
- Authenticate with your Charles Schwab account
- Automated refreshing of access token
- Download option chain data
- Get account information
- Place stock and option trades
- Retrieve trade history [Work in Progress]
- Monitor real-time market data [TODO]
Installation
To install the Charles Schwab API client, you can use pip:
pip install CSchwabPy
Usage Example
- Authentication & Get Access Token & Refresh Token
# save these lines in a file named like cschwab.py
# NOTE: should use SchwabClient to get tokens manually after version 0.1.3
from cschwabpy.SchwabClient import SchwabClient
app_client_key = "---your-app-client-key-here-"
app_secret = "app-secret"
schwab_client = SchwabClient(app_client_id=app_client_key, app_secret=app_secret)
schwab_client.get_tokens_manually()
# run in your Terminal, follow the prompt to complete authentication:
> python cschwab.py
# now you should have access token & refresh token downloaded to your device
#----------------
ticker = '$SPX'
# get option expirations:
expiration_list = schwab_client.get_option_expirations(underlying_symbol = ticker)
# download SPX option chains
from_date = 2024-07-01
to_date = 2024-07-01
opt_chain_result = schwab_client.download_option_chain(ticker, from_date, to_date)
# get call-put dataframe pairs by expiration
opt_df_pairs = opt_chain_result.to_dataframe_pairs_by_expiration()
for df in opt_df_pairs:
print(df.expiration)
print(f"call dataframe size: {df.call_df.shape}. expiration: {df.expiration}")
print(f"put dataframe size: {df.put_df.shape}. expiration: {df.expiration}")
print(df.call_df.head(5))
print(df.put_df.head(5))
Build & Release
git tag v0.1.3.9 git push origin tag v0.1.3.9
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cschwabpy-0.1.4.4.tar.gz.
File metadata
- Download URL: cschwabpy-0.1.4.4.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27fdd862b0f7a4a3c328c91dcd072956586f50765cccad270af0a6d17dd7612f
|
|
| MD5 |
63669e3caace635738c4a295dea784a4
|
|
| BLAKE2b-256 |
807053028dfe534e7ae98877976c72a465e111c6034a68d549ab9d0a6acb4491
|
Provenance
The following attestation bundles were made for cschwabpy-0.1.4.4.tar.gz:
Publisher:
pypi-publish.yml on rcholic/cschwab.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cschwabpy-0.1.4.4.tar.gz -
Subject digest:
27fdd862b0f7a4a3c328c91dcd072956586f50765cccad270af0a6d17dd7612f - Sigstore transparency entry: 155383793
- Sigstore integration time:
-
Permalink:
rcholic/cschwab.py@2b3f0b20593d08f544a92f5b4524b26871ba6ddb -
Branch / Tag:
refs/tags/v0.1.4.4 - Owner: https://github.com/rcholic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@2b3f0b20593d08f544a92f5b4524b26871ba6ddb -
Trigger Event:
push
-
Statement type:
File details
Details for the file cschwabpy-0.1.4.4-py3-none-any.whl.
File metadata
- Download URL: cschwabpy-0.1.4.4-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d7535bc6a36b2e02e1797f85bc2c32be2531a0d68c7e1ce0b9f15fb3e611170
|
|
| MD5 |
6640dca9bb2654529ef87949213818af
|
|
| BLAKE2b-256 |
30ebe35254ca98dbb400d97cbc47ae39ea756ccccc341bfba0c513456c6f3eaa
|
Provenance
The following attestation bundles were made for cschwabpy-0.1.4.4-py3-none-any.whl:
Publisher:
pypi-publish.yml on rcholic/cschwab.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cschwabpy-0.1.4.4-py3-none-any.whl -
Subject digest:
7d7535bc6a36b2e02e1797f85bc2c32be2531a0d68c7e1ce0b9f15fb3e611170 - Sigstore transparency entry: 155383794
- Sigstore integration time:
-
Permalink:
rcholic/cschwab.py@2b3f0b20593d08f544a92f5b4524b26871ba6ddb -
Branch / Tag:
refs/tags/v0.1.4.4 - Owner: https://github.com/rcholic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@2b3f0b20593d08f544a92f5b4524b26871ba6ddb -
Trigger Event:
push
-
Statement type: