Skip to main content

No project description provided

Project description

(Unofficial) Charles Schwab Stock and Option Trade API Client

License

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


Download files

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

Source Distribution

cschwabpy-0.1.4.8.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cschwabpy-0.1.4.8-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file cschwabpy-0.1.4.8.tar.gz.

File metadata

  • Download URL: cschwabpy-0.1.4.8.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

Hashes for cschwabpy-0.1.4.8.tar.gz
Algorithm Hash digest
SHA256 67b57d75c886ae7915b105d3a92fefcce9be97655c917ec69ae9e8908e1d921d
MD5 5c5e6c4672fa17505a20b9a590ce5364
BLAKE2b-256 ec20bdac0f7f82fd75e89eb4ce1c3a416425fb1e95a369a2d686c95ed08bf1c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for cschwabpy-0.1.4.8.tar.gz:

Publisher: pypi-publish.yml on rcholic/cschwab.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cschwabpy-0.1.4.8-py3-none-any.whl.

File metadata

  • Download URL: cschwabpy-0.1.4.8-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for cschwabpy-0.1.4.8-py3-none-any.whl
Algorithm Hash digest
SHA256 47056adc52dd12a4d3686a9986aa6305924b73d71a350fa4e4abcec2fc67b45c
MD5 634d893bb6b53cdba5b78ee94e483ecd
BLAKE2b-256 60cd9f8b44a255583af963ea47f0ae144b374842139fa447d415061625daa138

See more details on using hashes here.

Provenance

The following attestation bundles were made for cschwabpy-0.1.4.8-py3-none-any.whl:

Publisher: pypi-publish.yml on rcholic/cschwab.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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