Skip to content

Commit

Permalink
Merge pull request #3 from rcholic/modeling3
Browse files Browse the repository at this point in the history
readme example
  • Loading branch information
rcholic authored Jun 5, 2024
2 parents 9253280 + 8ad9237 commit e99971d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

```

0 comments on commit e99971d

Please sign in to comment.