Skip to content

Commit

Permalink
Add WS support for launchpad
Browse files Browse the repository at this point in the history
  • Loading branch information
antdjohns committed May 30, 2023
1 parent 04ea8a1 commit 8d79e2c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions polygon/websocket/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def parse_single(data: Dict[str, Any]):
return Level2Book.from_dict(data)
elif event_type == EventType.Value.value:
return IndexValue.from_dict(data)
elif event_type == EventType.LaunchpadValue.value:
return
return None


Expand Down
6 changes: 6 additions & 0 deletions polygon/websocket/models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Feed(Enum):
PolyFeed = "polyfeed.polygon.io"
PolyFeedPlus = "polyfeedplus.polygon.io"
StarterFeed = "starterfeed.polygon.io"
Launchpad = "launchpad.polygon.io"


class Market(Enum):
Expand All @@ -32,3 +33,8 @@ class EventType(Enum):
LimitUpLimitDown = "LULD"
CryptoL2 = "XL2"
Value = "V"
"""Launchpad* EventTypes are only available to Launchpad users. These values are the same across all asset classes (
stocks, options, forex, crypto).
"""
LaunchpadValue = "LV"
LaunchpadAggMin = "AM"
18 changes: 18 additions & 0 deletions polygon/websocket/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,23 @@ def from_dict(d):
)


@modelclass
class LaunchpadValue:
event_type: Optional[Union[str, EventType]] = None
value: Optional[float] = None
symbol: Optional[str] = None
timestamp: Optional[str] = None

@staticmethod
def from_dict(d):
return LaunchpadValue(
event_type=d.get("ev", None),
value=d.get("val", None),
symbol=d.get("sym", None),
timestamp=d.get("s", None),
)


WebSocketMessage = NewType(
"WebSocketMessage",
List[
Expand All @@ -340,6 +357,7 @@ def from_dict(d):
LimitUpLimitDown,
Level2Book,
IndexValue,
LaunchpadValue,
]
],
)

0 comments on commit 8d79e2c

Please sign in to comment.