Skip to content

Commit

Permalink
Fix FMV ws model and added example" (#566)
Browse files Browse the repository at this point in the history
* Fix FMV ws model and add example

* Updated example with correct tickers
  • Loading branch information
justinpolygon authored Nov 27, 2023
1 parent 7905faf commit ae03944
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
19 changes: 19 additions & 0 deletions examples/websocket/fmv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from polygon import WebSocketClient
from polygon.websocket.models import WebSocketMessage, Feed, Market
from typing import List

client = WebSocketClient(feed=Feed.Business, market=Market.Stocks, verbose=True)

# FMV
client.subscribe("FMV.*") # all ticker symbols
# client.subscribe("FMV.TSLA")
# client.subscribe("FMV.AAPL")
# client.subscribe("FMV.NVDA")


def handle_msg(msgs: List[WebSocketMessage]):
for m in msgs:
print(m)


client.run(handle_msg)
2 changes: 2 additions & 0 deletions polygon/websocket/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def parse_single(data: Dict[str, Any]):
return IndexValue.from_dict(data)
elif event_type == EventType.LaunchpadValue.value:
return LaunchpadValue.from_dict(data)
elif event_type == EventType.BusinessFairMarketValue.value:
return FairMarketValue.from_dict(data)
return None


Expand Down
3 changes: 2 additions & 1 deletion polygon/websocket/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class FairMarketValue:

@staticmethod
def from_dict(d):
return LaunchpadValue(
return FairMarketValue(
event_type=d.get("ev", None),
fmv=d.get("fmv", None),
ticker=d.get("sym", None),
Expand All @@ -375,6 +375,7 @@ def from_dict(d):
Level2Book,
IndexValue,
LaunchpadValue,
FairMarketValue,
]
],
)

0 comments on commit ae03944

Please sign in to comment.