Skip to content

Commit a2d9ce2

Browse files
QuenosGraeme22
andauthored
Update instruments.py (#192)
* Update instruments.py get_chain now returns a list with all chains * compact formatting --------- Co-authored-by: Graeme Holliday <[email protected]>
1 parent 699c4f6 commit a2d9ce2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tastytrade/instruments.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ class NestedOptionChain(TastytradeJsonDataclass):
660660
expirations: list[NestedOptionChainExpiration]
661661

662662
@classmethod
663-
async def a_get_chain(cls, session: Session, symbol: str) -> Self:
663+
async def a_get_chain(cls, session: Session, symbol: str) -> list[Self]:
664664
"""
665665
Gets the option chain for the given symbol in nested format.
666666
@@ -669,10 +669,10 @@ async def a_get_chain(cls, session: Session, symbol: str) -> Self:
669669
"""
670670
symbol = symbol.replace("/", "%2F")
671671
data = await session._a_get(f"/option-chains/{symbol}/nested")
672-
return cls(**data["items"][0])
672+
return [cls(**item) for item in data["items"]]
673673

674674
@classmethod
675-
def get_chain(cls, session: Session, symbol: str) -> Self:
675+
def get_chain(cls, session: Session, symbol: str) -> list[Self]:
676676
"""
677677
Gets the option chain for the given symbol in nested format.
678678
@@ -681,7 +681,7 @@ def get_chain(cls, session: Session, symbol: str) -> Self:
681681
"""
682682
symbol = symbol.replace("/", "%2F")
683683
data = session._get(f"/option-chains/{symbol}/nested")
684-
return cls(**data["items"][0])
684+
return [cls(**item) for item in data["items"]]
685685

686686

687687
class FutureProduct(TastytradeJsonDataclass):

0 commit comments

Comments
 (0)