cschwabpy


Namecschwabpy JSON
Version 0.1.4.3 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-09-07 20:27:53
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/be/cd/6e90edd9ff9d1752771ea05292dd7f50e2f8c23b942d26f2f5a67a6d545b/cschwabpy-0.1.4.3.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.3",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "149aba3919f863900b9c582765143805b0686ceb7f3b773263b5cf0a4646bb82",
                "md5": "9e4f18d49b2f78fa4b2d3e973f4e8aaa",
                "sha256": "0a0577ace6140e58cc5c92bdc01efa8183ef808011d388ffe647f5fa3774784a"
            },
            "downloads": -1,
            "filename": "cschwabpy-0.1.4.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9e4f18d49b2f78fa4b2d3e973f4e8aaa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 18088,
            "upload_time": "2024-09-07T20:27:52",
            "upload_time_iso_8601": "2024-09-07T20:27:52.181621Z",
            "url": "https://files.pythonhosted.org/packages/14/9a/ba3919f863900b9c582765143805b0686ceb7f3b773263b5cf0a4646bb82/cschwabpy-0.1.4.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "becd6e90edd9ff9d1752771ea05292dd7f50e2f8c23b942d26f2f5a67a6d545b",
                "md5": "60cc2072493c2e429476045ed068cefc",
                "sha256": "f1edf025afd02c765606c5b5664447d51cc4aac112c20c6001bdac8a38be8a91"
            },
            "downloads": -1,
            "filename": "cschwabpy-0.1.4.3.tar.gz",
            "has_sig": false,
            "md5_digest": "60cc2072493c2e429476045ed068cefc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 14412,
            "upload_time": "2024-09-07T20:27:53",
            "upload_time_iso_8601": "2024-09-07T20:27:53.504625Z",
            "url": "https://files.pythonhosted.org/packages/be/cd/6e90edd9ff9d1752771ea05292dd7f50e2f8c23b942d26f2f5a67a6d545b/cschwabpy-0.1.4.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-07 20:27:53",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cschwabpy"
}
        
Elapsed time: 0.58397s