Skip to content

Commit

Permalink
add fmv to snapshot and ws models and add new feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
morningvera committed Oct 19, 2023
1 parent d93ab7e commit d399d86
Show file tree
Hide file tree
Showing 9 changed files with 1,737 additions and 788 deletions.
2,479 changes: 1,692 additions & 787 deletions .polygon/rest.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions polygon/rest/models/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class TickerSnapshot:
todays_change: Optional[float] = None
todays_change_percent: Optional[float] = None
updated: Optional[int] = None
fair_market_value: Optional[float] = None

@staticmethod
def from_dict(d):
Expand All @@ -107,6 +108,7 @@ def from_dict(d):
todays_change=d.get("todaysChange", None),
todays_change_percent=d.get("todaysChangePerc", None),
updated=d.get("updated", None),
fair_market_value=d.get("fmv", None),
)


Expand Down Expand Up @@ -215,6 +217,7 @@ class OptionContractSnapshot:
last_trade: Optional[LastTradeOptionContractSnapshot] = None
open_interest: Optional[float] = None
underlying_asset: Optional[UnderlyingAsset] = None
fair_market_value: Optional[float] = None

@staticmethod
def from_dict(d):
Expand All @@ -238,6 +241,7 @@ def from_dict(d):
underlying_asset=None
if "underlying_asset" not in d
else UnderlyingAsset.from_dict(d["underlying_asset"]),
fair_market_value=d.get("fmv", None),
)


Expand Down Expand Up @@ -391,6 +395,7 @@ class UniversalSnapshot:
open_interest: Optional[float] = None
market_status: Optional[str] = None
name: Optional[str] = None
fair_market_value: Optional[float] = None
error: Optional[str] = None
message: Optional[str] = None

Expand Down Expand Up @@ -420,6 +425,7 @@ def from_dict(d):
open_interest=d.get("open_interest", None),
market_status=d.get("market_status", None),
name=d.get("name", None),
fair_market_value=d.get("fmv", None),
error=d.get("error", None),
message=d.get("message", None),
)
10 changes: 10 additions & 0 deletions polygon/websocket/models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ class Feed(Enum):
PolyFeedPlus = "polyfeedplus.polygon.io"
StarterFeed = "starterfeed.polygon.io"
Launchpad = "launchpad.polygon.io"
BusinessFeed = "business.polygon.io"
EdgxBusinessFeed = "edgx-business.polygon.io"
DelayedBusinessFeed = "delayed-business.polygon.io"
FullMarketBusinessFeed = "fullmarket-business.polygon.io"
NasdaqfeedLastSaleBusinessFeed = "nasdaqfeed-last-sale-business.polygon.io"
NasdaqfeedBasicBusinessFeed = "nasdaqfeed-basic-business.polygon.io"


class Market(Enum):
Expand Down Expand Up @@ -40,3 +46,7 @@ class EventType(Enum):
"""
LaunchpadValue = "LV"
LaunchpadAggMin = "AM"
"""Business* EventTypes are only available to Business users. These values are the same across all asset classes (
stocks, options, forex, crypto).
"""
BusinessFairMarketValue = "FMV"
17 changes: 17 additions & 0 deletions polygon/websocket/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,23 @@ def from_dict(d):
)


@modelclass
class FairMarketValue:
event_type: Optional[Union[str, EventType]] = None
fmv: Optional[float] = None
ticker: Optional[str] = None
timestamp: Optional[int] = None

@staticmethod
def from_dict(d):
return LaunchpadValue(
event_type=d.get("ev", None),
fmv=d.get("fmv", None),
ticker=d.get("sym", None),
timestamp=d.get("t", None),
)


WebSocketMessage = NewType(
"WebSocketMessage",
List[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"ticker": "AAPL",
"todaysChange": -3.65,
"todaysChangePerc": -2.231,
"updated": 1651251948294080343
"updated": 1651251948294080343,
"fair_market_value": 160.315
}
}
2 changes: 2 additions & 0 deletions test_rest/mocks/v3/snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"strike_price": 5,
"underlying_ticker": "NCLH"
},
"fmv": 20.5,
"greeks": {
"delta": 0.5520187372272933,
"gamma": 0.00706756515659829,
Expand Down Expand Up @@ -65,6 +66,7 @@
}
},
{
"fmv": 0.05,
"last_quote": {
"ask": 21.25,
"ask_size": 110,
Expand Down
1 change: 1 addition & 0 deletions test_rest/mocks/v3/snapshot/options/AAPL.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"strike_price": 150,
"ticker": "O:AAPL230616C00150000"
},
"fmv": 20.5,
"greeks": {
"delta": 0.6436614934293701,
"gamma": 0.0061735291012820675,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"strike_price": 150,
"ticker": "O:AAPL230616C00150000"
},
"fmv": 29.2,
"greeks": {
"delta": 0.6436614934293701,
"gamma": 0.0061735291012820675,
Expand Down
6 changes: 6 additions & 0 deletions test_rest/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_list_universal_snapshots(self):
strike_price=5,
underlying_ticker="NCLH",
),
fair_market_value=20.5,
greeks=Greeks(
delta=0.5520187372272933,
gamma=0.00706756515659829,
Expand Down Expand Up @@ -90,6 +91,7 @@ def test_list_universal_snapshots(self):
),
),
UniversalSnapshot(
fair_market_value=0.05,
last_quote=UniversalSnapshotLastQuote(
ask=21.25,
ask_size=110,
Expand Down Expand Up @@ -147,6 +149,7 @@ def test_get_snapshot_all(self):
timestamp=None,
transactions=None,
),
fair_market_value=20.5,
last_quote=LastQuote(
ticker=None,
trf_timestamp=None,
Expand Down Expand Up @@ -220,6 +223,7 @@ def test_get_snapshot_ticker(self):
timestamp=None,
transactions=None,
),
fair_market_value=20.5,
last_quote=LastQuote(
ticker=None,
trf_timestamp=None,
Expand Down Expand Up @@ -303,6 +307,7 @@ def test_get_snapshot_option(self):
strike_price=150,
ticker="O:AAPL230616C00150000",
),
fair_market_value=29.2,
greeks=Greeks(
delta=0.6436614934293701,
gamma=0.0061735291012820675,
Expand Down Expand Up @@ -363,6 +368,7 @@ def test_list_snapshot_options_chain(self):
strike_price=150,
ticker="O:AAPL230616C00150000",
),
fair_market_value=29.2,
greeks=Greeks(
delta=0.6436614934293701,
gamma=0.0061735291012820675,
Expand Down

0 comments on commit d399d86

Please sign in to comment.