diff --git a/polygon/websocket/__init__.py b/polygon/websocket/__init__.py index 4875a1ac..c86d0d7d 100644 --- a/polygon/websocket/__init__.py +++ b/polygon/websocket/__init__.py @@ -197,15 +197,26 @@ async def _unsubscribe(self, topics: Union[List[str], Set[str]]): self.json.dumps({"action": "unsubscribe", "params": subs}) ) + @staticmethod def _parse_subscription(s: str): s = s.strip() split = s.split(".") - if len(split) != 2: - logger.warning("invalid subscription:", s) - return [None, None] + length = len(split) + + match length: + case _ if length < 2: + logger.warning("invalid subscription:", s) + return [None, None] + case 3: + return split[0], split[1] + "." + split[2] + case _ if length > 3: + logger.warning("invalid subscription:", s) + return [None, None] + case _: + return split[0], split[1] + - return split def subscribe(self, *subscriptions: str): """