From 8ad92377c74c92fd0916697abbd445af1390634b Mon Sep 17 00:00:00 2001 From: rcholic Date: Tue, 4 Jun 2024 20:18:50 -0700 Subject: [PATCH] readme example --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index d6e8c4a..6363e1a 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,36 @@ This is a Python client library for accessing the Charles Schwab stock and optio ## 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 +from cschwabpy.SchwabAsyncClient import SchwabAsyncClient + +app_client_key = "---your-app-client-key-here-" +app_secret = "app-secret" + +schwab_client = SchwabAsyncClient(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 + +#---------------- +# download SPX option chains +from_date = 2024-07-01 +to_date = 2024-07-01 +ticker = '$SPX' +asyncio.run(schwab_client.download_option_chain(ticker, from_date, to_date)) + +```