From 13d157e5ee83e6da88386a5375b195549a5a1f83 Mon Sep 17 00:00:00 2001 From: Rene <56319882+rekroeg@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:03:36 +0100 Subject: [PATCH 1/4] Added error_message in case stop_trigger is missing --- tastytrade/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tastytrade/utils.py b/tastytrade/utils.py index 79932bb..2bf1a78 100644 --- a/tastytrade/utils.py +++ b/tastytrade/utils.py @@ -218,6 +218,9 @@ def validate_response(response: Response) -> None: errors = content.get('errors') if errors is not None: for error in errors: - error_message += f"\n{error['code']}: {error['message']}" + if "code" in error: + error_message += f"\n{error['code']}: {error['message']}" + else: + error_message += f"\n{error['domain']}: {error['reason']}" raise TastytradeError(error_message) From 5edb31cb6fef1159f35ebcadb6a2f1e92e94b357 Mon Sep 17 00:00:00 2001 From: Rene <56319882+rekroeg@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:09:18 +0100 Subject: [PATCH 2/4] complex-order.id can be int --- tastytrade/order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tastytrade/order.py b/tastytrade/order.py index abcc671..190f674 100644 --- a/tastytrade/order.py +++ b/tastytrade/order.py @@ -296,7 +296,7 @@ class PlacedComplexOrder(TastytradeJsonDataclass): account_number: str type: str orders: List[PlacedOrder] - id: Optional[str] = None + id: Optional[str|int] = None trigger_order: Optional[PlacedOrder] = None terminal_at: Optional[str] = None ratio_price_threshold: Optional[Decimal] = None From 2b05179a43c280e903f09137d191b4c6b60d1cf9 Mon Sep 17 00:00:00 2001 From: Rene <56319882+rekroeg@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:21:25 +0100 Subject: [PATCH 3/4] Changed type of preflight_id and complex_order_id --- tastytrade/order.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tastytrade/order.py b/tastytrade/order.py index 190f674..5c0fb08 100644 --- a/tastytrade/order.py +++ b/tastytrade/order.py @@ -283,9 +283,9 @@ class PlacedOrder(TastytradeJsonDataclass): user_id: Optional[str] = None username: Optional[str] = None terminal_at: Optional[datetime] = None - complex_order_id: Optional[str] = None + complex_order_id: Optional[str|int] = None complex_order_tag: Optional[str] = None - preflight_id: Optional[str] = None + preflight_id: Optional[str|int] = None order_rule: Optional[OrderRule] = None From f8c55a78948a37b12b9d960b8ada4458f91748d3 Mon Sep 17 00:00:00 2001 From: Rene <56319882+rekroeg@users.noreply.github.com> Date: Sat, 9 Mar 2024 13:08:40 +0100 Subject: [PATCH 4/4] Changed from | to Union --- tastytrade/order.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tastytrade/order.py b/tastytrade/order.py index 5c0fb08..70160db 100644 --- a/tastytrade/order.py +++ b/tastytrade/order.py @@ -1,7 +1,7 @@ from datetime import date, datetime from decimal import Decimal from enum import Enum -from typing import Dict, List, Optional +from typing import Dict, List, Optional, Union from tastytrade import VERSION from tastytrade.utils import TastytradeJsonDataclass @@ -283,9 +283,9 @@ class PlacedOrder(TastytradeJsonDataclass): user_id: Optional[str] = None username: Optional[str] = None terminal_at: Optional[datetime] = None - complex_order_id: Optional[str|int] = None + complex_order_id: Optional[Union[str, int]] = None complex_order_tag: Optional[str] = None - preflight_id: Optional[str|int] = None + preflight_id: Optional[Union[str, int]] = None order_rule: Optional[OrderRule] = None @@ -296,7 +296,7 @@ class PlacedComplexOrder(TastytradeJsonDataclass): account_number: str type: str orders: List[PlacedOrder] - id: Optional[str|int] = None + id: Optional[Union[str, int]] = None trigger_order: Optional[PlacedOrder] = None terminal_at: Optional[str] = None ratio_price_threshold: Optional[Decimal] = None