Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add last trade #404

Merged
merged 4 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions polygon/rest/models/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ class LastQuoteOptionContractSnapshot:
def from_dict(d):
return LastQuoteOptionContractSnapshot(**d)

@modelclass
class LastTradeOptionContractSnapshot:
"Contains data for the most recent trade for an options contract."
price: Optional[float] = None
sip_timestamp: Optional[int] = None
size: Optional[int] = None
conditions: Optional[List[int]] = None
exchange: Optional[int] = None
timeframe: Optional[str] = None

@staticmethod
def from_dict(d):
return LastTradeOptionContractSnapshot(**d)


@modelclass
class Greeks:
Expand Down Expand Up @@ -149,6 +163,7 @@ class OptionContractSnapshot:
greeks: Optional[Greeks] = None
implied_volatility: Optional[float] = None
last_quote: Optional[LastQuoteOptionContractSnapshot] = None
last_trade: Optional[LastTradeOptionContractSnapshot] = None
open_interest: Optional[float] = None
underlying_asset: Optional[UnderlyingAsset] = None

Expand Down
10 changes: 9 additions & 1 deletion test_rest/mocks/v3/snapshot/options/AAPL.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
"midpoint": 29.075,
"timeframe": "REAL-TIME"
},
"last_trade":{
"price": 29.25,
"sip_timestamp": 1678718527714665700,
"size": 1,
"conditions": [209],
"exchange": 309,
"timeframe": "REAL-TIME"
},
"open_interest": 8133,
"underlying_asset": {
"change_to_break_even": 19.11439999999999,
Expand All @@ -49,4 +57,4 @@
}
}],
"status": "OK"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
"midpoint": 29.075,
"timeframe": "REAL-TIME"
},
"last_trade":{
"price": 29.25,
"sip_timestamp": 1678718527714665700,
"size": 1,
"conditions": [209],
"exchange": 309,
"timeframe": "REAL-TIME"
},
"open_interest": 8133,
"underlying_asset": {
"change_to_break_even": 19.11439999999999,
Expand All @@ -48,4 +56,4 @@
}
},
"status": "OK"
}
}
17 changes: 17 additions & 0 deletions test_rest/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
OrderBookQuote,
UnderlyingAsset,
LastQuoteOptionContractSnapshot,
LastTradeOptionContractSnapshot,
Greeks,
OptionDetails,
DayOptionContractSnapshot,
Expand Down Expand Up @@ -199,6 +200,14 @@ def test_get_snapshot_option(self):
midpoint=29.075,
timeframe="REAL-TIME",
),
last_trade=LastTradeOptionContractSnapshot(
price=29.25,
sip_timestamp=1678718527714665700,
size=1,
conditions=[209],
exchange=309,
timeframe="REAL-TIME",
),
open_interest=8133,
underlying_asset=UnderlyingAsset(
change_to_break_even=19.11439999999999,
Expand Down Expand Up @@ -251,6 +260,14 @@ def test_list_snapshot_options_chain(self):
midpoint=29.075,
timeframe="REAL-TIME",
),
last_trade=LastTradeOptionContractSnapshot(
price=29.25,
sip_timestamp=1678718527714665700,
size=1,
conditions=[209],
exchange=309,
timeframe="REAL-TIME",
),
open_interest=8133,
underlying_asset=UnderlyingAsset(
change_to_break_even=19.11439999999999,
Expand Down