Skip to content

Commit

Permalink
add docs, fix a couple tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Graeme22 committed Oct 9, 2024
1 parent 00f9cc5 commit 96ae495
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Fixes ...

## Pre-merge checklist
- [ ] Code formatted correctly with `uv run ruff format .`
- [ ] Code implemented for both sync and async
- [ ] Passing tests locally
- [ ] New tests added (if applicable)

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
project = "tastytrade"
copyright = "2024, Graeme Holliday"
author = "Graeme Holliday"
release = "8.6"
release = "9.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Tastytrade Python SDK
=====================

A simple, reverse-engineered SDK for Tastytrade built on their (now mostly public) API. This will allow you to create trading algorithms for whatever strategies you may have quickly and painlessly in Python.
A simple, reverse-engineered, sync/async SDK for Tastytrade built on their (now mostly public) API. This will allow you to create trading algorithms for whatever strategies you may have quickly and painlessly in Python.

.. tip::
Want to see the SDK in action? Check out `tastytrade-cli <https://github.com/tastyware/tastytrade-cli>`_, a CLI for Tastytrade that showcases many of the SDK's features.
Expand All @@ -24,6 +24,7 @@ A simple, reverse-engineered SDK for Tastytrade built on their (now mostly publi

installation
sessions
sync-async
accounts
instruments
orders
Expand Down
27 changes: 27 additions & 0 deletions docs/sync-async.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
sync/async
==========

After creating a session (which is always initialized synchronously), the rest of the API endpoints implemented in the SDK have both sync and async implementations as of version 9.0.

Let's see how this looks:

.. code-block:: python
from tastytrade Account, Session
session = Session(username, password)
# using sync implementation
accounts = Account.get_accounts(session)
The async implementation is similar:

.. code-block:: python
from tastytrade Account, Session
session = Session(username, password)
# using async implementation
accounts = await Account.a_get_accounts(session)
That's it! All sync methods have a parallel async method that starts with `a_`.

.. note::
Please note that two modules, `tastytrade.backtest` and `tastytrade.streamer`, only have async implementations. But for everything else, you can use what you'd like!
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "tastytrade"
version = "8.6"
version = "9.0"
description = "An unofficial SDK for Tastytrade!"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
2 changes: 1 addition & 1 deletion tastytrade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
API_URL = "https://api.tastyworks.com"
BACKTEST_URL = "https://backtester.vast.tastyworks.com"
CERT_URL = "https://api.cert.tastyworks.com"
VERSION = "8.6"
VERSION = "9.0"

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ def test_get_live_complex_orders(session, account):

@fixture(scope="module")
async def placed_order_async(session, account, new_order):
return await account.a_place_order(session, new_order, dry_run=False).order
res = await account.a_place_order(session, new_order, dry_run=False)
return res.order


async def test_get_order_async(session, account, placed_order_async):
Expand All @@ -268,6 +269,7 @@ async def test_replace_and_delete_order_async(session, account, new_order, place


async def test_place_complex_order_async(session, account):
sleep(3)
symbol = Equity.get_equity(session, "AAPL")
opening = symbol.build_leg(Decimal(1), OrderAction.BUY_TO_OPEN)
closing = symbol.build_leg(Decimal(1), OrderAction.SELL_TO_CLOSE)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_watchlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def test_get_private_watchlist_async(session):


async def test_update_private_watchlist_async(session, private_wl):
private_wl.remove_symbol("AAPL", InstrumentType.EQUITY)
private_wl.remove_symbol("MSFT", InstrumentType.EQUITY)
sleep(1)
await private_wl.a_update_private_watchlist(session)

Expand Down

0 comments on commit 96ae495

Please sign in to comment.