Python SDK for trading Kalshi and Polymarket US with your own keys: paper mode by default, guardrails, backtests, and fee math that matches each venue.
See the codeTrade prediction markets on Kalshi and Polymarket US from Python, with your own venue keys.
One order shape for every venue. Paper mode by default: real order books, simulated money. Guardrails on every order. Fee math that matches each venue's published schedule to the millionth of a dollar. Everything runs on your machine.
Website · Docs · PyPI · Example bot
pip install uselayer # Python 3.11+
from uselayer import Client
client = Client() # paper mode: real books, simulated fills
m = client.markets(limit=20)[0] # open Polymarket US markets, no key needed
book = client.book(m.slug)
order = client.order(
venue="polymarket_us", market=m.slug, side="yes", price=book.outcome("yes").best_ask.price, size=5
)
print(client.preview(order)) # fill, fees, every rule's decision
print(client.send(order)) # the order, filled against the book
client.matches() returns markets that are the same bet on both venues, and buy_best() places your order on whichever is cheaper after fees. Give it contracts, or a dollar amount (spend=50) and it buys where that money wins more.quote() prices a cross-venue pair after fees, depth and return per day; trade() buys both sides only if the gap is still there.python/: the uselayer package. Full guide in python/README.md, runnable examples in python/examples/.schema/order.json: the order shape every venue and mode shares, as JSON Schema.fee-golden.json: Layer's own fee answers, which the SDK's fee math is tested against.MIT licensed.
Python SDK for trading Kalshi and Polymarket US with your own keys: paper mode by default, guardrails, backtests, and fee math that matches each venue.
See the codeTrade prediction markets on Kalshi and Polymarket US from Python, with your own venue keys.
One order shape for every venue. Paper mode by default: real order books, simulated money. Guardrails on every order. Fee math that matches each venue's published schedule to the millionth of a dollar. Everything runs on your machine.
Website · Docs · PyPI · Example bot
pip install uselayer # Python 3.11+
from uselayer import Client
client = Client() # paper mode: real books, simulated fills
m = client.markets(limit=20)[0] # open Polymarket US markets, no key needed
book = client.book(m.slug)
order = client.order(
venue="polymarket_us", market=m.slug, side="yes", price=book.outcome("yes").best_ask.price, size=5
)
print(client.preview(order)) # fill, fees, every rule's decision
print(client.send(order)) # the order, filled against the book
client.matches() returns markets that are the same bet on both venues, and buy_best() places your order on whichever is cheaper after fees. Give it contracts, or a dollar amount (spend=50) and it buys where that money wins more.quote() prices a cross-venue pair after fees, depth and return per day; trade() buys both sides only if the gap is still there.python/: the uselayer package. Full guide in python/README.md, runnable examples in python/examples/.schema/order.json: the order shape every venue and mode shares, as JSON Schema.fee-golden.json: Layer's own fee answers, which the SDK's fee math is tested against.MIT licensed.