Explicit Chainlink selection
PolyNodeWS when selections must be isolated.
Read the shared short-form guide for market fields, manual mode, and orderbook integration.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Rotate Python subscriptions across short-form crypto markets with the correct Chainlink TWAP window.
| Market interval | Chainlink selection |
|---|---|
5m | 30 seconds |
15m | 60 seconds |
1h | default spot feed |
4h | 60 seconds |
import asyncio
import os
from polynode import AsyncPolyNode
async def main() -> None:
async with AsyncPolyNode(api_key=os.environ["POLYNODE_API_KEY"]) as pn:
stream = pn.ws.short_form(
"5m",
coins=["btc", "eth", "sol"],
)
def on_rotation(rotation) -> None:
for market in rotation.markets:
print({
"coin": market.coin,
"slug": market.slug,
"feed": market.chainlink_feed,
"twap_window_seconds": market.twap_window_seconds,
"price_to_beat": market.price_to_beat,
})
stream.on("rotation", on_rotation)
stream.on("settlement", print)
stream.on("error", print)
try:
await asyncio.Event().wait()
finally:
stream.stop()
pn.ws.disconnect()
asyncio.run(main())
prices = await (
pn.ws.subscribe("chainlink")
.feeds(["BTC/USD", "ETH/USD"])
.twap_windows([30, 60])
.send()
)
print(prices.price_source, prices.twap_windows)
prices.on("price_feed", lambda event: print(
event.feed, event.price, event.is_twap, event.twap_window_seconds
))
PolyNodeWS when selections must be isolated.
Read the shared short-form guide for market fields, manual mode, and orderbook integration.