Skip to content

Instantly share code, notes, and snippets.

@poly-rodr
poly-rodr / ws-new-messages.py
Last active December 29, 2025 00:33
New messages: new markets, markets resolved and best bid/ask
import asyncio
import orjson
import websockets
async def send_ping(websocket: websockets.WebSocketClientProtocol, interval=5):
"""Send ping to keep the WebSocket connection alive."""
try:
while True:
await asyncio.sleep(interval) # Wait for the specified interval
@poly-rodr
poly-rodr / clob-websockets.py
Created December 18, 2025 18:15
Subscribing / unsubscribing from assets within the same WebSockets connection
import asyncio
import orjson
import websockets
async def send_ping(websocket: websockets.WebSocketClientProtocol, interval=5):
"""Send ping to keep the WebSocket connection alive."""
try:
while True:
await asyncio.sleep(interval) # Wait for the specified interval
@poly-rodr
poly-rodr / websocket-api-changes.md
Last active December 18, 2025 20:11
A summary with the changes of the new version of the WebSocket API.

Changes in the WebSocket API

Price change event

Current version

If you are subscribed to the market stream you are receiving price_change events like these:

{
@poly-rodr
poly-rodr / recovering-funds-magic-email.md
Created July 22, 2024 14:56
Recovering funds from an email account.
@poly-rodr
poly-rodr / set_allowances.py
Last active December 25, 2025 13:20
CLOB Allowance Setting Python + Neg Risk
from web3 import Web3
from web3.constants import MAX_INT
from web3.middleware import geth_poa_middleware
rpc_url = "" # Polygon rpc url
priv_key = "" # Polygon account private key (needs some MATIC)
pub_key = "" # Polygon account public key corresponding to private key
chain_id = 137