cschwabpy


Namecschwabpy JSON
Version 0.1.4.5 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-12-17 01:22:24
maintainerNone
docs_urlNone
authorTony Wang
requires_python<4.0,>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # (Unofficial) Charles Schwab Stock and Option Trade API Client

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

## 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

- [x] Authenticate with your Charles Schwab account
- [X] Automated refreshing of access token
- [x] Download option chain data
- [x] Get account information
- [x] 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

```python

# 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


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cschwabpy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Tony Wang",
    "author_email": "ivytony@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/09/d8/47becbcbeff028997eff5baf2ea8e00d7adee2cb5fa8181a1b1774db0ad1/cschwabpy-0.1.4.5.tar.gz",
    "platform": null,
    "description": "# (Unofficial) Charles Schwab Stock and Option Trade API Client\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n## Overview\n\nThis 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.\n\n## Features\n\n- [x] Authenticate with your Charles Schwab account\n- [X] Automated refreshing of access token\n- [x] Download option chain data\n- [x] Get account information\n- [x] Place stock and option trades\n- Retrieve trade history [Work in Progress]\n- Monitor real-time market data [TODO]\n\n## Installation\n\nTo install the Charles Schwab API client, you can use pip:\n```\npip install CSchwabPy\n```\n\n## Usage Example\n\n* Authentication & Get Access Token & Refresh Token\n\n```python\n\n# save these lines in a file named like cschwab.py\n# NOTE: should use SchwabClient to get tokens manually after version 0.1.3\nfrom cschwabpy.SchwabClient import SchwabClient\n\napp_client_key = \"---your-app-client-key-here-\"\napp_secret = \"app-secret\"\n\nschwab_client = SchwabClient(app_client_id=app_client_key, app_secret=app_secret)\nschwab_client.get_tokens_manually()\n\n# run in your Terminal, follow the prompt to complete authentication:\n> python cschwab.py\n\n\n# now you should have access token & refresh token downloaded to your device\n\n#----------------\nticker = '$SPX'\n# get option expirations:\nexpiration_list = schwab_client.get_option_expirations(underlying_symbol = ticker)\n\n# download SPX option chains\nfrom_date = 2024-07-01\nto_date = 2024-07-01\n\nopt_chain_result = schwab_client.download_option_chain(ticker, from_date, to_date)\n\n# get call-put dataframe pairs by expiration\nopt_df_pairs = opt_chain_result.to_dataframe_pairs_by_expiration()\n\nfor df in opt_df_pairs:\n    print(df.expiration)\n    print(f\"call dataframe size: {df.call_df.shape}. expiration: {df.expiration}\")\n    print(f\"put dataframe size: {df.put_df.shape}. expiration: {df.expiration}\")\n    print(df.call_df.head(5))\n    print(df.put_df.head(5))\n\n```\n\n##### Build & Release\ngit tag v0.1.3.9\ngit push origin tag v0.1.3.9\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": null,
    "version": "0.1.4.5",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f7b5814cddededcb5df3433887a60a77372e986260ac4615264e4e9ac3ec035",
                "md5": "5e7c70fea2d17ef898a3a87e16cf876d",
                "sha256": "cccae437450e05d9ca3029b5c1286038f9069b153ee40007effd3d5c72085a2e"
            },
            "downloads": -1,
            "filename": "cschwabpy-0.1.4.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5e7c70fea2d17ef898a3a87e16cf876d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 18280,
            "upload_time": "2024-12-17T01:22:22",
            "upload_time_iso_8601": "2024-12-17T01:22:22.882425Z",
            "url": "https://files.pythonhosted.org/packages/3f/7b/5814cddededcb5df3433887a60a77372e986260ac4615264e4e9ac3ec035/cschwabpy-0.1.4.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09d847becbcbeff028997eff5baf2ea8e00d7adee2cb5fa8181a1b1774db0ad1",
                "md5": "60f9c8b2ca1e49c9f7e62ece4820ae47",
                "sha256": "55c106ba2cf28a04d861b332da69f354e81e590107dd5427e93b4ffb902a926c"
            },
            "downloads": -1,
            "filename": "cschwabpy-0.1.4.5.tar.gz",
            "has_sig": false,
            "md5_digest": "60f9c8b2ca1e49c9f7e62ece4820ae47",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 14640,
            "upload_time": "2024-12-17T01:22:24",
            "upload_time_iso_8601": "2024-12-17T01:22:24.649009Z",
            "url": "https://files.pythonhosted.org/packages/09/d8/47becbcbeff028997eff5baf2ea8e00d7adee2cb5fa8181a1b1774db0ad1/cschwabpy-0.1.4.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 01:22:24",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cschwabpy"
}
        
Elapsed time: 0.39172s