From 293c08d3ea84cccd4a99a7c395b98171dc16b0c9 Mon Sep 17 00:00:00 2001 From: Graeme Holliday Date: Tue, 10 Sep 2024 14:55:48 -0500 Subject: [PATCH] fix several bugs --- docs/conf.py | 2 +- setup.py | 2 +- tastytrade/__init__.py | 4 +++- tastytrade/dxfeed/quote.py | 6 ++++-- tastytrade/instruments.py | 15 ++++++++------- tastytrade/order.py | 2 +- tastytrade/watchlists.py | 4 ++-- 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 4e3e776..31fab8c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,7 +9,7 @@ project = 'tastytrade' copyright = '2024, Graeme Holliday' author = 'Graeme Holliday' -release = '8.2' +release = '8.3' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/setup.py b/setup.py index b97e510..fb31bf9 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name='tastytrade', - version='8.2', + version='8.3', description='An unofficial SDK for Tastytrade!', long_description=LONG_DESCRIPTION, long_description_content_type='text/markdown', diff --git a/tastytrade/__init__.py b/tastytrade/__init__.py index 7a6365a..d8623c1 100644 --- a/tastytrade/__init__.py +++ b/tastytrade/__init__.py @@ -2,7 +2,7 @@ API_URL = 'https://api.tastyworks.com' CERT_URL = 'https://api.cert.tastyworks.com' -VERSION = '8.2' +VERSION = '8.3' logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) @@ -10,6 +10,7 @@ # flake8: noqa from .account import Account +from .dxfeed import EventType from .instruments import (Cryptocurrency, Equity, Future, FutureOption, FutureOptionProduct, FutureProduct, NestedFutureOptionChain, NestedOptionChain, Option, @@ -38,6 +39,7 @@ 'Cryptocurrency', 'DXLinkStreamer', 'Equity', + 'EventType', 'Future', 'FutureOption', 'FutureOptionProduct', diff --git a/tastytrade/dxfeed/quote.py b/tastytrade/dxfeed/quote.py index 07e6e44..468d494 100644 --- a/tastytrade/dxfeed/quote.py +++ b/tastytrade/dxfeed/quote.py @@ -30,6 +30,8 @@ class Quote(Event): #: ask price askPrice: Optional[Decimal] = None #: bid size as integer number (rounded toward zero) - bidSize: Optional[int] = None + #: or decimal for cryptocurrencies + bidSize: Optional[Decimal] = None #: ask size as integer number (rounded toward zero) - askSize: Optional[int] = None + #. or decimal for cryptocurrencies + askSize: Optional[Decimal] = None diff --git a/tastytrade/instruments.py b/tastytrade/instruments.py index 3244504..fee16e1 100644 --- a/tastytrade/instruments.py +++ b/tastytrade/instruments.py @@ -461,17 +461,18 @@ def occ_to_streamer_symbol(cls, occ) -> str: :param occ: the OCC symbol to convert """ + symbol = occ[:6].split()[0] + info = occ[6:] match = re.match( - r'([A-Z]+)\s+(\d{6})([CP])(\d{5})(\d{3})', - occ + r'(\d{6})([CP])(\d{5})(\d{3})', + info ) if match is None: return '' - symbol = match.group(1) - exp = match.group(2) - option_type = match.group(3) - strike = int(match.group(4)) - decimal = int(match.group(5)) + exp = match.group(1) + option_type = match.group(2) + strike = int(match.group(3)) + decimal = int(match.group(4)) res = f'.{symbol}{exp}{option_type}{strike}' if decimal != 0: diff --git a/tastytrade/order.py b/tastytrade/order.py index 8c2c023..b3c522b 100644 --- a/tastytrade/order.py +++ b/tastytrade/order.py @@ -263,7 +263,7 @@ class PlacedOrder(TastytradeJsonDataclass): edited: bool updated_at: datetime legs: List[Leg] - size: Optional[int] = None + size: Optional[Decimal] = None id: Optional[int] = None price: Optional[Decimal] = None price_effect: Optional[PriceEffect] = None diff --git a/tastytrade/watchlists.py b/tastytrade/watchlists.py index fa8a7ed..44a599e 100644 --- a/tastytrade/watchlists.py +++ b/tastytrade/watchlists.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional +from typing import Any, Dict, List, Optional from tastytrade.instruments import InstrumentType from tastytrade.session import Session @@ -60,7 +60,7 @@ class Watchlist(TastytradeJsonDataclass): with functions to update, publish, modify and remove watchlists. """ name: str - watchlist_entries: Optional[List[Dict[str, str]]] = None + watchlist_entries: Optional[List[Dict[str, Any]]] = None group_name: str = 'default' order_index: int = 9999