1
1
from datetime import date , datetime
2
2
from decimal import Decimal
3
- from typing import Any , Dict , List , Literal , Optional , Union
3
+ from typing import Any , Literal , Optional , Union
4
4
5
5
import httpx
6
6
from pydantic import BaseModel , model_validator
@@ -229,7 +229,7 @@ class MarginReportEntry(TastytradeJsonDataclass):
229
229
margin_requirement : Decimal
230
230
expected_price_range_up_percent : Optional [Decimal ] = None
231
231
expected_price_range_down_percent : Optional [Decimal ] = None
232
- groups : Optional [List [ Dict [str , Any ]]] = None
232
+ groups : Optional [list [ dict [str , Any ]]] = None
233
233
initial_requirement : Optional [Decimal ] = None
234
234
maintenance_requirement : Optional [Decimal ] = None
235
235
point_of_no_return_percent : Optional [Decimal ] = None
@@ -269,7 +269,7 @@ class MarginReport(TastytradeJsonDataclass):
269
269
reg_t_option_buying_power : Decimal
270
270
maintenance_excess : Decimal
271
271
last_state_timestamp : int
272
- groups : List [Union [MarginReportEntry , EmptyDict ]]
272
+ groups : list [Union [MarginReportEntry , EmptyDict ]]
273
273
initial_requirement : Optional [Decimal ] = None
274
274
275
275
@model_validator (mode = "before" )
@@ -430,7 +430,7 @@ class Transaction(TastytradeJsonDataclass):
430
430
other_charge_description : Optional [str ] = None
431
431
reverses_id : Optional [int ] = None
432
432
cost_basis_reconciliation_date : Optional [date ] = None
433
- lots : Optional [List [Lot ]] = None
433
+ lots : Optional [list [Lot ]] = None
434
434
agency_price : Optional [Decimal ] = None
435
435
principal_price : Optional [Decimal ] = None
436
436
@@ -484,7 +484,7 @@ class Account(TastytradeJsonDataclass):
484
484
submitting_user_id : Optional [str ] = None
485
485
486
486
@classmethod
487
- async def a_get_accounts (cls , session : Session , include_closed = False ) -> List [Self ]:
487
+ async def a_get_accounts (cls , session : Session , include_closed = False ) -> list [Self ]:
488
488
"""
489
489
Gets all trading accounts associated with the Tastytrade user.
490
490
@@ -500,7 +500,7 @@ async def a_get_accounts(cls, session: Session, include_closed=False) -> List[Se
500
500
]
501
501
502
502
@classmethod
503
- def get_accounts (cls , session : Session , include_closed = False ) -> List [Self ]:
503
+ def get_accounts (cls , session : Session , include_closed = False ) -> list [Self ]:
504
504
"""
505
505
Gets all trading accounts associated with the Tastytrade user.
506
506
@@ -583,7 +583,7 @@ async def a_get_balance_snapshots(
583
583
start_date : Optional [date ] = None ,
584
584
snapshot_date : Optional [date ] = None ,
585
585
time_of_day : Literal ["BOD" , "EOD" ] = "EOD" ,
586
- ) -> List [AccountBalanceSnapshot ]:
586
+ ) -> list [AccountBalanceSnapshot ]:
587
587
"""
588
588
Returns a list of balance snapshots. This list will
589
589
just have a few snapshots if you don't pass a start
@@ -646,7 +646,7 @@ def get_balance_snapshots(
646
646
start_date : Optional [date ] = None ,
647
647
snapshot_date : Optional [date ] = None ,
648
648
time_of_day : Literal ["BOD" , "EOD" ] = "EOD" ,
649
- ) -> List [AccountBalanceSnapshot ]:
649
+ ) -> list [AccountBalanceSnapshot ]:
650
650
"""
651
651
Returns a list of balance snapshots. This list will
652
652
just have a few snapshots if you don't pass a start
@@ -702,15 +702,15 @@ def get_balance_snapshots(
702
702
async def a_get_positions (
703
703
self ,
704
704
session : Session ,
705
- underlying_symbols : Optional [List [str ]] = None ,
705
+ underlying_symbols : Optional [list [str ]] = None ,
706
706
symbol : Optional [str ] = None ,
707
707
instrument_type : Optional [InstrumentType ] = None ,
708
708
include_closed : Optional [bool ] = None ,
709
709
underlying_product_code : Optional [str ] = None ,
710
- partition_keys : Optional [List [str ]] = None ,
710
+ partition_keys : Optional [list [str ]] = None ,
711
711
net_positions : Optional [bool ] = None ,
712
712
include_marks : Optional [bool ] = None ,
713
- ) -> List [CurrentPosition ]:
713
+ ) -> list [CurrentPosition ]:
714
714
"""
715
715
Get the current positions of the account.
716
716
@@ -747,15 +747,15 @@ async def a_get_positions(
747
747
def get_positions (
748
748
self ,
749
749
session : Session ,
750
- underlying_symbols : Optional [List [str ]] = None ,
750
+ underlying_symbols : Optional [list [str ]] = None ,
751
751
symbol : Optional [str ] = None ,
752
752
instrument_type : Optional [InstrumentType ] = None ,
753
753
include_closed : Optional [bool ] = None ,
754
754
underlying_product_code : Optional [str ] = None ,
755
- partition_keys : Optional [List [str ]] = None ,
755
+ partition_keys : Optional [list [str ]] = None ,
756
756
net_positions : Optional [bool ] = None ,
757
757
include_marks : Optional [bool ] = None ,
758
- ) -> List [CurrentPosition ]:
758
+ ) -> list [CurrentPosition ]:
759
759
"""
760
760
Get the current positions of the account.
761
761
@@ -796,8 +796,8 @@ async def a_get_history(
796
796
page_offset : Optional [int ] = None ,
797
797
sort : str = "Desc" ,
798
798
type : Optional [str ] = None ,
799
- types : Optional [List [str ]] = None ,
800
- sub_types : Optional [List [str ]] = None ,
799
+ types : Optional [list [str ]] = None ,
800
+ sub_types : Optional [list [str ]] = None ,
801
801
start_date : Optional [date ] = None ,
802
802
end_date : Optional [date ] = None ,
803
803
instrument_type : Optional [InstrumentType ] = None ,
@@ -808,7 +808,7 @@ async def a_get_history(
808
808
futures_symbol : Optional [str ] = None ,
809
809
start_at : Optional [datetime ] = None ,
810
810
end_at : Optional [datetime ] = None ,
811
- ) -> List [Transaction ]:
811
+ ) -> list [Transaction ]:
812
812
"""
813
813
Get transaction history of the account.
814
814
@@ -891,8 +891,8 @@ def get_history(
891
891
page_offset : Optional [int ] = None ,
892
892
sort : str = "Desc" ,
893
893
type : Optional [str ] = None ,
894
- types : Optional [List [str ]] = None ,
895
- sub_types : Optional [List [str ]] = None ,
894
+ types : Optional [list [str ]] = None ,
895
+ sub_types : Optional [list [str ]] = None ,
896
896
start_date : Optional [date ] = None ,
897
897
end_date : Optional [date ] = None ,
898
898
instrument_type : Optional [InstrumentType ] = None ,
@@ -903,7 +903,7 @@ def get_history(
903
903
futures_symbol : Optional [str ] = None ,
904
904
start_at : Optional [datetime ] = None ,
905
905
end_at : Optional [datetime ] = None ,
906
- ) -> List [Transaction ]:
906
+ ) -> list [Transaction ]:
907
907
"""
908
908
Get transaction history of the account.
909
909
@@ -1036,7 +1036,7 @@ async def a_get_net_liquidating_value_history(
1036
1036
session : Session ,
1037
1037
time_back : Optional [str ] = None ,
1038
1038
start_time : Optional [datetime ] = None ,
1039
- ) -> List [NetLiqOhlc ]:
1039
+ ) -> list [NetLiqOhlc ]:
1040
1040
"""
1041
1041
Returns a list of account net liquidating value snapshots over the
1042
1042
specified time period.
@@ -1070,7 +1070,7 @@ def get_net_liquidating_value_history(
1070
1070
session : Session ,
1071
1071
time_back : Optional [str ] = None ,
1072
1072
start_time : Optional [datetime ] = None ,
1073
- ) -> List [NetLiqOhlc ]:
1073
+ ) -> list [NetLiqOhlc ]:
1074
1074
"""
1075
1075
Returns a list of account net liquidating value snapshots over the
1076
1076
specified time period.
@@ -1175,7 +1175,7 @@ def get_margin_requirements(self, session: Session) -> MarginReport:
1175
1175
data = session ._get (f"/margin/accounts/{ self .account_number } /requirements" )
1176
1176
return MarginReport (** data )
1177
1177
1178
- async def a_get_live_orders (self , session : Session ) -> List [PlacedOrder ]:
1178
+ async def a_get_live_orders (self , session : Session ) -> list [PlacedOrder ]:
1179
1179
"""
1180
1180
Get orders placed today for the account.
1181
1181
@@ -1184,7 +1184,7 @@ async def a_get_live_orders(self, session: Session) -> List[PlacedOrder]:
1184
1184
data = await session ._a_get (f"/accounts/{ self .account_number } /orders/live" )
1185
1185
return [PlacedOrder (** i ) for i in data ["items" ]]
1186
1186
1187
- def get_live_orders (self , session : Session ) -> List [PlacedOrder ]:
1187
+ def get_live_orders (self , session : Session ) -> list [PlacedOrder ]:
1188
1188
"""
1189
1189
Get orders placed today for the account.
1190
1190
@@ -1195,7 +1195,7 @@ def get_live_orders(self, session: Session) -> List[PlacedOrder]:
1195
1195
1196
1196
async def a_get_live_complex_orders (
1197
1197
self , session : Session
1198
- ) -> List [PlacedComplexOrder ]:
1198
+ ) -> list [PlacedComplexOrder ]:
1199
1199
"""
1200
1200
Get complex orders placed today for the account.
1201
1201
@@ -1206,7 +1206,7 @@ async def a_get_live_complex_orders(
1206
1206
)
1207
1207
return [PlacedComplexOrder (** i ) for i in data ["items" ]]
1208
1208
1209
- def get_live_complex_orders (self , session : Session ) -> List [PlacedComplexOrder ]:
1209
+ def get_live_complex_orders (self , session : Session ) -> list [PlacedComplexOrder ]:
1210
1210
"""
1211
1211
Get complex orders placed today for the account.
1212
1212
@@ -1309,13 +1309,13 @@ async def a_get_order_history(
1309
1309
start_date : Optional [date ] = None ,
1310
1310
end_date : Optional [date ] = None ,
1311
1311
underlying_symbol : Optional [str ] = None ,
1312
- statuses : Optional [List [OrderStatus ]] = None ,
1312
+ statuses : Optional [list [OrderStatus ]] = None ,
1313
1313
futures_symbol : Optional [str ] = None ,
1314
1314
underlying_instrument_type : Optional [InstrumentType ] = None ,
1315
1315
sort : Optional [str ] = None ,
1316
1316
start_at : Optional [datetime ] = None ,
1317
1317
end_at : Optional [datetime ] = None ,
1318
- ) -> List [PlacedOrder ]:
1318
+ ) -> list [PlacedOrder ]:
1319
1319
"""
1320
1320
Get order history of the account.
1321
1321
@@ -1390,13 +1390,13 @@ def get_order_history(
1390
1390
start_date : Optional [date ] = None ,
1391
1391
end_date : Optional [date ] = None ,
1392
1392
underlying_symbol : Optional [str ] = None ,
1393
- statuses : Optional [List [OrderStatus ]] = None ,
1393
+ statuses : Optional [list [OrderStatus ]] = None ,
1394
1394
futures_symbol : Optional [str ] = None ,
1395
1395
underlying_instrument_type : Optional [InstrumentType ] = None ,
1396
1396
sort : Optional [str ] = None ,
1397
1397
start_at : Optional [datetime ] = None ,
1398
1398
end_at : Optional [datetime ] = None ,
1399
- ) -> List [PlacedOrder ]:
1399
+ ) -> list [PlacedOrder ]:
1400
1400
"""
1401
1401
Get order history of the account.
1402
1402
@@ -1465,7 +1465,7 @@ def get_order_history(
1465
1465
1466
1466
async def a_get_complex_order_history (
1467
1467
self , session : Session , per_page : int = 50 , page_offset : Optional [int ] = None
1468
- ) -> List [PlacedComplexOrder ]:
1468
+ ) -> list [PlacedComplexOrder ]:
1469
1469
"""
1470
1470
Get order history of the account.
1471
1471
@@ -1504,7 +1504,7 @@ async def a_get_complex_order_history(
1504
1504
1505
1505
def get_complex_order_history (
1506
1506
self , session : Session , per_page : int = 50 , page_offset : Optional [int ] = None
1507
- ) -> List [PlacedComplexOrder ]:
1507
+ ) -> list [PlacedComplexOrder ]:
1508
1508
"""
1509
1509
Get order history of the account.
1510
1510
@@ -1653,7 +1653,7 @@ async def a_get_order_chains(
1653
1653
symbol : str ,
1654
1654
start_time : datetime ,
1655
1655
end_time : datetime ,
1656
- ) -> List [OrderChain ]:
1656
+ ) -> list [OrderChain ]:
1657
1657
"""
1658
1658
Get a list of order chains (open + rolls + close) for given symbol
1659
1659
over the given time frame, with total P/L, commissions, etc.
@@ -1692,7 +1692,7 @@ def get_order_chains(
1692
1692
symbol : str ,
1693
1693
start_time : datetime ,
1694
1694
end_time : datetime ,
1695
- ) -> List [OrderChain ]:
1695
+ ) -> list [OrderChain ]:
1696
1696
"""
1697
1697
Get a list of order chains (open + rolls + close) for given symbol
1698
1698
over the given time frame, with total P/L, commissions, etc.
0 commit comments