Extending the Service
How to Add a New Watcher
Create a module in
polymarket_watcher/watchers/, e.g.smart_money_watcher.py.Subclass
BaseWatcher:from ..watchers.base_watcher import BaseWatcher from typing import Any, FrozenSet class SmartMoneyWatcher(BaseWatcher): supported_event_types: FrozenSet[str] = frozenset({"price_change"}) @property def name(self) -> str: return "SmartMoneyWatcher" def on_event(self, event: dict[str, Any]) -> None: # Inspect the event and fire actions if relevant. ...
Add configuration (optional) — add a new dataclass to
config.pyand a matching YAML key inconfig.yaml.Register the watcher — inside
WatcherService._build_watchers()inservice.py, instantiate and append your watcher:if cfg.watcher.smart_money.enabled: watchers.append(SmartMoneyWatcher(..., actions=actions))
That’s it — no other file needs to change.
How to Add a New Action
Create a module in
polymarket_watcher/actions/, e.g.discord_action.py.Subclass
BaseAction:import httpx from .base_action import BaseAction from typing import Any class DiscordAction(BaseAction): def __init__(self, webhook_url: str) -> None: self._webhook_url = webhook_url @property def name(self) -> str: return "DiscordAction" def execute(self, event_data: dict[str, Any]) -> None: content = f"🚨 **{event_data['watcher']}** alert\n```json\n{event_data}\n```" httpx.post(self._webhook_url, json={"content": content})
Wire the action — in
WatcherService._build_watchers(), add it to theactionslist:actions = [LogAction(), DiscordAction(webhook_url=cfg.actions.discord.webhook_url)]