Skip to content

Commit ae03944

Browse files
Fix FMV ws model and added example" (#566)
* Fix FMV ws model and add example * Updated example with correct tickers
1 parent 7905faf commit ae03944

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

examples/websocket/fmv.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from polygon import WebSocketClient
2+
from polygon.websocket.models import WebSocketMessage, Feed, Market
3+
from typing import List
4+
5+
client = WebSocketClient(feed=Feed.Business, market=Market.Stocks, verbose=True)
6+
7+
# FMV
8+
client.subscribe("FMV.*") # all ticker symbols
9+
# client.subscribe("FMV.TSLA")
10+
# client.subscribe("FMV.AAPL")
11+
# client.subscribe("FMV.NVDA")
12+
13+
14+
def handle_msg(msgs: List[WebSocketMessage]):
15+
for m in msgs:
16+
print(m)
17+
18+
19+
client.run(handle_msg)

polygon/websocket/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def parse_single(data: Dict[str, Any]):
3535
return IndexValue.from_dict(data)
3636
elif event_type == EventType.LaunchpadValue.value:
3737
return LaunchpadValue.from_dict(data)
38+
elif event_type == EventType.BusinessFairMarketValue.value:
39+
return FairMarketValue.from_dict(data)
3840
return None
3941

4042

polygon/websocket/models/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ class FairMarketValue:
351351

352352
@staticmethod
353353
def from_dict(d):
354-
return LaunchpadValue(
354+
return FairMarketValue(
355355
event_type=d.get("ev", None),
356356
fmv=d.get("fmv", None),
357357
ticker=d.get("sym", None),
@@ -375,6 +375,7 @@ def from_dict(d):
375375
Level2Book,
376376
IndexValue,
377377
LaunchpadValue,
378+
FairMarketValue,
378379
]
379380
],
380381
)

0 commit comments

Comments
 (0)