Skip to content

Commit

Permalink
docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
Graeme22 committed Jan 14, 2025
1 parent 2488ac6 commit eca1890
Show file tree
Hide file tree
Showing 9 changed files with 854 additions and 28 deletions.
19 changes: 10 additions & 9 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.10"
os: "ubuntu-22.04"
tools:
python: "3.10"
commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv sync --dev
- uv run -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html
sphinx:
configuration: docs/conf.py
python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .
configuration: docs/conf.py

formats: all
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: install lint test
.PHONY: install lint test docs

install:
uv sync
Expand All @@ -11,3 +11,6 @@ lint:

test:
uv run pytest --cov=tastytrade --cov-report=term-missing tests/ --cov-fail-under=95

docs:
uv run -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs/ docs/_build/
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"sphinx.ext.doctest",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
# "sphinx.ext.intersphinx",
"sphinx_toolbox.more_autodoc.autotypeddict",
"sphinx.ext.intersphinx",
"enum_tools.autoenum",
"sphinxcontrib.autodoc_pydantic",
]
Expand Down
8 changes: 4 additions & 4 deletions docs/data-streamer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Once you've created the streamer, you can subscribe/unsubscribe to events, like
break
print(quotes)
>>> [{'SPY': Quote(eventSymbol='SPY', eventTime=0, sequence=0, timeNanoPart=0, bidTime=0, bidExchangeCode='Q', bidPrice=411.58, bidSize=400.0, askTime=0, askExchangeCode='Q', askPrice=411.6, askSize=1313.0), 'SPX': Quote(eventSymbol='SPX', eventTime=0, sequence=0, timeNanoPart=0, bidTime=0, bidExchangeCode='\x00', bidPrice=4122.49, bidSize='NaN', askTime=0, askExchangeCode='\x00', askPrice=4123.65, askSize='NaN')}]
>>> [{'SPY': Quote(event_symbol='SPY', event_time=0, sequence=0, time_nano_part=0, bid_time=0, bid_exchange_code='Q', bid_price=411.58, bid_size=400.0, ask_time=0, ask_exchange_code='Q', ask_price=411.6, ask_size=1313.0), 'SPX': Quote(event_symbol='SPX', event_time=0, sequence=0, time_nano_part=0, bid_time=0, bid_exchange_code='\x00', bid_price=4122.49, bid_size='NaN', ask_time=0, ask_exchange_code='\x00', ask_price=4123.65, ask_size='NaN')}]

Note that these are ``asyncio`` calls, so you'll need to run this code asynchronously. Here's an example:

Expand All @@ -51,7 +51,7 @@ Note that these are ``asyncio`` calls, so you'll need to run this code asynchron
asyncio.run(main(session))
>>> [Quote(eventSymbol='SPY', eventTime=0, sequence=0, timeNanoPart=0, bidTime=0, bidExchangeCode='Q', bidPrice=411.58, bidSize=400.0, askTime=0, askExchangeCode='Q', askPrice=411.6, askSize=1313.0), Quote(eventSymbol='SPX', eventTime=0, sequence=0, timeNanoPart=0, bidTime=0, bidExchangeCode='\x00', bidPrice=4122.49, bidSize='NaN', askTime=0, askExchangeCode='\x00', askPrice=4123.65, askSize='NaN')]
>>> [Quote(event_symbol='SPY', event_time=0, sequence=0, time_nano_part=0, bid_time=0, bid_exchange_code='Q', bid_price=411.58, bid_size=400.0, ask_time=0, ask_exchange_code='Q', ask_price=411.6, ask_size=1313.0), Quote(event_symbol='SPX', event_time=0, sequence=0, time_nanoPart=0, bid_time=0, bid_exchange_code='\x00', bid_price=4122.49, bid_size='NaN', ask_time=0, ask_exchange_code='\x00', ask_price=4123.65, ask_size='NaN')]

Alternatively, you can do testing in a Jupyter notebook, which allows you to make async calls directly, or run a python shell like this: `python -m asyncio`.

Expand All @@ -72,7 +72,7 @@ We can also use the streamer to stream greeks for options symbols:
greeks = await streamer.get_event(Greeks)
print(greeks)
>>> [Greeks(eventSymbol='.SPLG230616C23', eventTime=0, eventFlags=0, index=7235129486797176832, time=1684559855338, sequence=0, price=26.3380972233688, volatility=0.396983376650804, delta=0.999999999996191, gamma=4.81989763184255e-12, theta=-2.5212017514875e-12, rho=0.01834504287973133, vega=3.7003015672215e-12)]
>>> [Greeks(event_symbol='.SPLG230616C23', event_time=0, event_flags=0, index=7235129486797176832, time=1684559855338, sequence=0, price=26.3380972233688, volatility=0.396983376650804, delta=0.999999999996191, gamma=4.81989763184255e-12, theta=-2.5212017514875e-12, rho=0.01834504287973133, vega=3.7003015672215e-12)]

Advanced usage
--------------
Expand Down Expand Up @@ -145,7 +145,7 @@ Now, we can access the quotes and greeks at any time, and they'll be up-to-date
symbol = live_prices.calls[44].streamer_symbol
print(live_prices.quotes[symbol], live_prices.greeks[symbol])
>>> Quote(eventSymbol='.SPY230721C387', eventTime=0, sequence=0, timeNanoPart=0, bidTime=1689365699000, bidExchangeCode='X', bidPrice=62.01, bidSize=50.0, askTime=1689365699000, askExchangeCode='X', askPrice=62.83, askSize=50.0) Greeks(eventSymbol='.SPY230721C387', eventTime=0, eventFlags=0, index=7255910303911641088, time=1689398266363, sequence=0, price=62.6049270064687, volatility=0.536152815048564, delta=0.971506591907638, gamma=0.001814464566110275, theta=-0.1440768557397271, rho=0.0831882577866199, vega=0.0436861878838861)
>>> Quote(event_symbol='.SPY230721C387', event_time=0, sequence=0, time_nano_part=0, bid_time=1689365699000, bid_exchange_code='X', bid_price=62.01, bid_size=50.0, ask_time=1689365699000, ask_exchange_code='X', ask_price=62.83, ask_size=50.0) Greeks(event_symbol='.SPY230721C387', event_time=0, event_flags=0, index=7255910303911641088, time=1689398266363, sequence=0, price=62.6049270064687, volatility=0.536152815048564, delta=0.971506591907638, gamma=0.001814464566110275, theta=-0.1440768557397271, rho=0.0831882577866199, vega=0.0436861878838861)

Retry callback
--------------
Expand Down
8 changes: 2 additions & 6 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,12 @@ If you want to build the documentation (usually not necessary):

::

$ source .venv/bin/activate
$ cd docs
$ uv pip install -r requirements.txt
$ make html
$ make docs

Windows
-------

If you want to install from source on Windows, you'll need to either use Cygwin/WSL, or run the commands from the Makefile manually.
Here's an example for PowerShell:
If you want to install from source on Windows, you can't use the Makefile, so just run the commands individually. For example:

::

Expand Down
5 changes: 0 additions & 5 deletions docs/requirements.txt

This file was deleted.

4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ dev-dependencies = [
"pytest-cov>=5.0.0",
"ruff>=0.6.9",
"pyright>=1.1.390",
"sphinx>=7.4.7",
"sphinx-rtd-theme>=3.0.2",
"enum-tools[sphinx]>=0.12.0",
"autodoc-pydantic>=2.2.0",
]

[tool.setuptools.package-data]
Expand Down
2 changes: 1 addition & 1 deletion tastytrade/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class Session:
Contains a local user login which can then be used to interact with the
remote API.
:param login: tastytrade username or email
:param login: Tastytrade username or email
:param remember_me:
whether or not to create a remember token to use instead of a password
:param password:
Expand Down
Loading

0 comments on commit eca1890

Please sign in to comment.