Skip to content

Commit

Permalink
Sync point: Relevant documentation is copied
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgolec committed Apr 14, 2024
1 parent ef3faf9 commit b801eb9
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
Binary file added docs/_static/warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions docs/client.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
.. highlight:: python
.. py:module:: schwab.client
.. image:: _static/warning.png
:width: 40

**WARNING!!! schwab-py is pre-alpha! Use at your own risk!**


.. _client:

===========
Expand All @@ -14,6 +21,56 @@ client provides access to all endpoints of the API in as easy and direct a way
as possible.


**Do not attempt to use more than one Client object per token file, as
this will likely cause issues with the underlying OAuth2 session management**

.. code-block:: python
from schwab.auth import easy_client
from schwab.client import Client
# Follow the instructions on the screen to authenticate your client.
c = client_from_manual_flow(
api_key='APIKEY',
app_secret='APP_SECRET',
callback_url='https://127.0.0.1',
token_path='/tmp/token.json')
resp = c.get_price_history_every_day('AAPL')
assert resp.status_code == httpx.codes.OK
history = resp.json()
Note we we create a new client using the ``auth`` package as described in
:ref:`auth`. Creating a client directly is possible, but not recommended.

+++++++++++++++++++
Asyncio Support
+++++++++++++++++++

An asynchronous variant is available through a keyword to the client
constructor. This allows for higher-performance API usage, at the cost
of slightly increased application complexity.

.. code-block:: python
from schwab.auth import easy_client
from schwab.client import Client
async def main():
c = easy_client(
api_key='APIKEY',
redirect_uri='https://localhost',
token_path='/tmp/token.json',
asyncio=True)
resp = await c.c.get_price_history_every_day('AAPL')
assert resp.status_code == httpx.codes.OK
history = resp.json()
if __name__ == '__main__':
import asyncio
asyncio.run_until_complete(main())
+++++++++++++++++++
Calling Conventions
+++++++++++++++++++
Expand Down Expand Up @@ -85,6 +142,18 @@ number to the account hash that must be passed when referring to that account in
API calls.


++++++++++++++++++
Timeout Management
++++++++++++++++++

Timeouts for HTTP calls are managed under the hood by the ``httpx`` library.
``schwab-py`` defaults to 30 seconds, which experience has shown should be more
than enough to allow even the slowest API calls to complete. A different timeout
specification can be set using this method:

.. automethod:: schwab.client.Client.set_timeout


++++++++++++
Account Info
++++++++++++
Expand Down Expand Up @@ -145,6 +214,30 @@ history endpoint, in all its complexity.

.. _orders-section:

++++++++++++++
Current Quotes
++++++++++++++

.. automethod:: schwab.client.Client.get_quote
.. automethod:: schwab.client.Client.get_quotes

.. _option_chain:

+++++++++++++
Option Chains
+++++++++++++

Unfortunately, option chains are well beyond the ability of your humble author.
You are encouraged to read the official API documentation to learn more.

If you *are* knowledgeable enough to write something more substantive here,
please follow the instructions in :ref:`contributing` to send in a patch.

.. automethod:: schwab.client.Client.get_option_chain
.. autoclass:: schwab.client.Client.Options
:members:
:undoc-members:

++++++
Orders
++++++
Expand Down
5 changes: 5 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
``schwab-py``: An Unofficial Charles Schwab API Client
======================================================

.. image:: _static/warning.png
:width: 40

**WARNING!!! schwab-py is pre-alpha! Use at your own risk!**

.. image:: _static/github-logo.png
:width: 40
:target: https://github.com/alexgolec/tda-api
Expand Down
5 changes: 5 additions & 0 deletions docs/order-builder.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.. py:module:: schwab.orders.generic
.. image:: _static/warning.png
:width: 40

**WARNING!!! schwab-py is pre-alpha! Use at your own risk!**

.. _order_builder:

==========================
Expand Down
5 changes: 5 additions & 0 deletions docs/order-templates.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.. py:module:: schwab.orders
.. image:: _static/warning.png
:width: 40

**WARNING!!! schwab-py is pre-alpha! Use at your own risk!**

.. _order_templates:

===============
Expand Down

0 comments on commit b801eb9

Please sign in to comment.