Skip to content

Commit 7e24c7a

Browse files
committed
update instruments w pagination, fix #275
1 parent 35eb4ce commit 7e24c7a

File tree

2 files changed

+18
-84
lines changed

2 files changed

+18
-84
lines changed

tastytrade/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22

33
API_URL = "https://api.tastyworks.com"
4-
API_VERSION = "20250813"
4+
API_VERSION = "20251026"
55
CERT_URL = "https://api.cert.tastyworks.com"
66
VAST_URL = "https://vast.tastyworks.com"
77
VERSION = "11.0.0"

tastytrade/instruments.py

Lines changed: 17 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -756,21 +756,12 @@ class FutureProduct(TastytradeData):
756756

757757
@overload
758758
@classmethod
759-
async def a_get(
760-
cls,
761-
session: Session,
762-
*,
763-
per_page: int = 50,
764-
page_offset: int | None = 0,
765-
) -> list[Self]: ...
759+
async def a_get(cls, session: Session) -> list[Self]: ...
766760

767761
@overload
768762
@classmethod
769763
async def a_get(
770-
cls,
771-
session: Session,
772-
code: str,
773-
exchange: str = "CME",
764+
cls, session: Session, code: str, exchange: str = "CME"
774765
) -> Self: ...
775766

776767
@classmethod
@@ -779,8 +770,6 @@ async def a_get(
779770
session: Session,
780771
code: str | None = None,
781772
exchange: str = "CME",
782-
per_page: int = 250,
783-
page_offset: int | None = 0,
784773
) -> Self | list[Self]:
785774
"""
786775
Returns a list of FutureProduct objects available, or a single
@@ -790,48 +779,30 @@ async def a_get(
790779
:param code: the product code, e.g. 'ES'
791780
:param exchange:
792781
the exchange to fetch from: 'CME', 'SMALLS', 'CFE', 'CBOED'
793-
:param per_page: the number of options to get per page.
794-
:param page_offset:
795-
provide a specific page to get; if None, get all pages
796782
"""
797783
if code:
798784
code = code.replace("/", "")
799785
data = await session._a_get(
800786
f"/instruments/future-products/{exchange}/{code}"
801787
)
802788
return cls(**data)
803-
params = {"per-page": per_page, "page-offset": page_offset}
804-
return await a_paginate(
805-
session.async_client, cls, "/instruments/future-products", params
806-
)
789+
data = await session._a_get("/instruments/future-products")
790+
return [cls(**i) for i in data["items"]]
807791

808792
@overload
809793
@classmethod
810-
def get(
811-
cls,
812-
session: Session,
813-
*,
814-
per_page: int = 50,
815-
page_offset: int | None = 0,
816-
) -> list[Self]: ...
794+
def get(cls, session: Session) -> list[Self]: ...
817795

818796
@overload
819797
@classmethod
820-
def get(
821-
cls,
822-
session: Session,
823-
code: str,
824-
exchange: str = "CME",
825-
) -> Self: ...
798+
def get(cls, session: Session, code: str, exchange: str = "CME") -> Self: ...
826799

827800
@classmethod
828801
def get(
829802
cls,
830803
session: Session,
831804
code: str | None = None,
832805
exchange: str = "CME",
833-
per_page: int = 50,
834-
page_offset: int | None = 0,
835806
) -> Self | list[Self]:
836807
"""
837808
Returns a list of FutureProduct objects available, or a single
@@ -841,18 +812,13 @@ def get(
841812
:param code: the product code, e.g. 'ES'
842813
:param exchange:
843814
the exchange to fetch from: 'CME', 'SMALLS', 'CFE', 'CBOED'
844-
:param per_page: the number of options to get per page.
845-
:param page_offset:
846-
provide a specific page to get; if None, get all pages
847815
"""
848816
if code:
849817
code = code.replace("/", "")
850818
data = session._get(f"/instruments/future-products/{exchange}/{code}")
851819
return cls(**data)
852-
params = {"per-page": per_page, "page-offset": page_offset}
853-
return paginate(
854-
session.sync_client, cls, "/instruments/future-products", params
855-
)
820+
data = session._get("/instruments/future-products")
821+
return [cls(**i) for i in data["items"]]
856822

857823

858824
class Future(TradeableTastytradeData):
@@ -867,7 +833,6 @@ class Future(TradeableTastytradeData):
867833
display_factor: Decimal
868834
last_trade_date: date
869835
expiration_date: date
870-
closing_only_date: date
871836
active: bool
872837
active_month: bool
873838
next_active_month: bool
@@ -880,6 +845,7 @@ class Future(TradeableTastytradeData):
880845
back_month_first_calendar_symbol: bool
881846
instrument_type: InstrumentType = InstrumentType.FUTURE
882847
streamer_symbol: str = ""
848+
closing_only_date: date | None = None
883849
is_tradeable: bool | None = None
884850
future_product: "FutureProduct | None" = None
885851
contract_size: Decimal | None = None
@@ -1027,21 +993,12 @@ class FutureOptionProduct(TastytradeData):
1027993

1028994
@overload
1029995
@classmethod
1030-
async def a_get(
1031-
cls,
1032-
session: Session,
1033-
*,
1034-
per_page: int = 250,
1035-
page_offset: int | None = 0,
1036-
) -> list[Self]: ...
996+
async def a_get(cls, session: Session) -> list[Self]: ...
1037997

1038998
@overload
1039999
@classmethod
10401000
async def a_get(
1041-
cls,
1042-
session: Session,
1043-
root_symbol: str,
1044-
exchange: str = "CME",
1001+
cls, session: Session, root_symbol: str, exchange: str = "CME"
10451002
) -> Self: ...
10461003

10471004
@classmethod
@@ -1050,8 +1007,6 @@ async def a_get(
10501007
session: Session,
10511008
root_symbol: str | None = None,
10521009
exchange: str = "CME",
1053-
per_page: int = 250,
1054-
page_offset: int | None = 0,
10551010
) -> Self | list[Self]:
10561011
"""
10571012
Returns a list of FutureOptionProduct objects available, or a single
@@ -1060,43 +1015,27 @@ async def a_get(
10601015
:param session: the session to use for the request.
10611016
:param root_symbol: the root symbol of the future option
10621017
:param exchange: the exchange to get the product from
1063-
:param per_page: the number of options to get per page.
1064-
:param page_offset:
1065-
provide a specific page to get; if None, get all pages
10661018
"""
10671019
if root_symbol:
10681020
root_symbol = root_symbol.replace("/", "")
10691021
data = await session._a_get(
10701022
f"/instruments/future-option-products/{exchange}/{root_symbol}"
10711023
)
10721024
return cls(**data)
1073-
params = {"per-page": per_page, "page-offset": page_offset}
1074-
return await a_paginate(
1075-
session.async_client, cls, "/instruments/future-option-products", params
1076-
)
1025+
data = await session._a_get("/instruments/future-option-products")
1026+
return [cls(**i) for i in data["items"]]
10771027

10781028
@overload
10791029
@classmethod
1080-
def get(
1081-
cls,
1082-
session: Session,
1083-
*,
1084-
per_page: int = 250,
1085-
page_offset: int | None = 0,
1086-
) -> list[Self]: ...
1030+
def get(cls, session: Session) -> list[Self]: ...
10871031

10881032
@overload
10891033
@classmethod
10901034
def get(cls, session: Session, root_symbol: str, exchange: str = "CME") -> Self: ...
10911035

10921036
@classmethod
10931037
def get(
1094-
cls,
1095-
session: Session,
1096-
root_symbol: str | None = None,
1097-
exchange: str = "CME",
1098-
per_page: int = 250,
1099-
page_offset: int | None = 0,
1038+
cls, session: Session, root_symbol: str | None = None, exchange: str = "CME"
11001039
) -> Self | list[Self]:
11011040
"""
11021041
Returns a list of FutureOptionProduct objects available, or a single
@@ -1105,20 +1044,15 @@ def get(
11051044
:param session: the session to use for the request.
11061045
:param root_symbol: the root symbol of the future option
11071046
:param exchange: the exchange to get the product from
1108-
:param per_page: the number of options to get per page.
1109-
:param page_offset:
1110-
provide a specific page to get; if None, get all pages
11111047
"""
11121048
if root_symbol:
11131049
root_symbol = root_symbol.replace("/", "")
11141050
data = session._get(
11151051
f"/instruments/future-option-products/{exchange}/{root_symbol}"
11161052
)
11171053
return cls(**data)
1118-
params = {"per-page": per_page, "page-offset": page_offset}
1119-
return paginate(
1120-
session.sync_client, cls, "/instruments/future-option-products", params
1121-
)
1054+
data = session._get("/instruments/future-option-products")
1055+
return [cls(**i) for i in data["items"]]
11221056

11231057

11241058
class FutureOption(TradeableTastytradeData):

0 commit comments

Comments
 (0)