cschwabpy


Namecschwabpy JSON
Version 0.1.4.8 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-12-31 02:57:19
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/ec/20/bdac0f7f82fd75e89eb4ce1c3a416425fb1e95a369a2d686c95ed08bf1c7/cschwabpy-0.1.4.8.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.8",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "60cd9f8b44a255583af963ea47f0ae144b374842139fa447d415061625daa138",
                "md5": "634d893bb6b53cdba5b78ee94e483ecd",
                "sha256": "47056adc52dd12a4d3686a9986aa6305924b73d71a350fa4e4abcec2fc67b45c"
            },
            "downloads": -1,
            "filename": "cschwabpy-0.1.4.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "634d893bb6b53cdba5b78ee94e483ecd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 18215,
            "upload_time": "2024-12-31T02:57:16",
            "upload_time_iso_8601": "2024-12-31T02:57:16.745696Z",
            "url": "https://files.pythonhosted.org/packages/60/cd/9f8b44a255583af963ea47f0ae144b374842139fa447d415061625daa138/cschwabpy-0.1.4.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ec20bdac0f7f82fd75e89eb4ce1c3a416425fb1e95a369a2d686c95ed08bf1c7",
                "md5": "5c5e6c4672fa17505a20b9a590ce5364",
                "sha256": "67b57d75c886ae7915b105d3a92fefcce9be97655c917ec69ae9e8908e1d921d"
            },
            "downloads": -1,
            "filename": "cschwabpy-0.1.4.8.tar.gz",
            "has_sig": false,
            "md5_digest": "5c5e6c4672fa17505a20b9a590ce5364",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 14592,
            "upload_time": "2024-12-31T02:57:19",
            "upload_time_iso_8601": "2024-12-31T02:57:19.132157Z",
            "url": "https://files.pythonhosted.org/packages/ec/20/bdac0f7f82fd75e89eb4ce1c3a416425fb1e95a369a2d686c95ed08bf1c7/cschwabpy-0.1.4.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-31 02:57:19",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cschwabpy"
}
        
Elapsed time: 1.10217s