跳到正文
Hacker News· pemakenemi56·· 10 天前AI 评分45

Layer 推出统一 API:一个接口同时接入 Polymarket 与 Kalshi

Show HN: Layer – One API for Polymarket and Kalshi

AI 导读

Layer 发布面向交易机器人和 AI 智能体的统一 API,让同一份策略代码同时运行在 Kalshi 和 Polymarket US 上,目前已在两家平台上线。

正文 · 原文

For developers building trading bots and AI agents

Build your trading bot once. Run it across markets.

Layer tells your bot or AI agent which markets are the same bet, shows prices and order books in one format, places and cancels orders, and reports what filled. You write the strategy. Layer handles the venues.

LIVEWorks today with Kalshi and Polymarket US. Built for every market a program can trade.

one bet, two venues · illustrative

kalshiWill the Federal Reserve cut rates by 25bps at their December 2026 meeting?yes 0.42 · settles on federalreserve.gov

polymarket usWill the Fed decrease interest rates by 25 bps after the December 2026 meeting?yes 0.41 · settles on the FOMC statement

layersame bet · 0.85 confidence · caveat: rounding differs

your botdecides what to do with it

the problem

You wanted to build a strategy. You ended up rebuilding every venue.

Layer takes this list off your plate.

01The same event has a different name, id and settlement rule on every venue.

02Prices come in different formats. Fees follow different formulas.

03Every venue has its own keys, order types, errors and rate limits.

04Then you do it all again for the next venue.

what developers build

Your bot makes the calls. Layer does the legwork.

Your bot decides what counts as a good trade. Layer makes sure it is comparing the same thing, at the real price, and tells it what happened.

“I know what I want to trade. Help my bot find the best place to trade it.”

  1. your botWants YES on a December Fed cut, up to $500.
  2. layerFinds the same bet on each venue and flags where the rules differ.
  3. layerShows each venue’s order book and the real cost after fees, side by side.
  4. your botPicks the venue, or splits the order across venues for size.
  5. layerPlaces the order, checks it against your limits, and reports the fill.

“Watch every venue and tell my bot when the same bet is priced differently.”

  1. layerKeeps thousands of matched markets up to date, each with a confidence score and rule caveats.
  2. layerGives your bot live books in one format, so it compares like with like.
  3. layerWorks out the real cost after fees and how much size is actually there.
  4. your botDecides whether the difference is worth trading.
  5. layerPlaces both sides in paper mode, sells back the first if the second doesn’t fill, and reports the result. Live, both sides in one order is coming next.

“Let my AI agent trade the news, with a $200 daily budget.”

  1. your botReads the news and decides what it believes.
  2. layerTells it which markets on which venues ask that question.
  3. your botSends an order.
  4. layerChecks it against the budget, position limits and allowed markets before it goes out.
  5. layerStops everything when you hit the kill switch. Only a person can turn it back on.

how it works

The developer’s journey

01 understand

“Is this market the same bet as that one?”

Venues word the same event differently, and sometimes settle it differently. Layer reads both sets of rules, tells you whether it’s the same bet, flags what differs, and checks again after it settles.

Reads each venue’s settlement rules, not just the titleFlags different resolution sources and roundingRe-checks when a venue edits its rulesChecks every match again after it settles

02 see

“What does it really cost, on every venue?”

Prices, order books and fees from every venue in one format. A quoted price isn’t your price, so your bot sees the cost after fees and how much it can actually buy.

Fed cuts 25 bps in December · buy yes · 100 contracts · illustrative

venuebest askfeeall-in

kalshi0.42$1.71$43.71

polymarket us0.43$0.20$43.20

cheapest all-in · polymarket us340 available

fees vary by venue and market

03 trade

“Place this order. Cancel that one.”

One way to place and cancel orders on every venue, from your own account. Change the venue, keep the code.

python

# the same bet on each venue
pair = client.matches(q="fed december")[0]

# one way to place and cancel, on every venue
o = client.buy(
    venue="kalshi",
    market=pair.kalshi,
    side="yes", price=0.42, size=100,
)
client.cancel(o)

o = client.buy(
    venue="polymarket_us",
    market=pair.polymarket_us,
    side="yes", price=0.41, size=100,
)
o.status   # "filled"

04 trust

“What filled, what do I own, and did it make money?”

Fills, positions, balances and profit after fees, in one format across venues. You know what actually happened, not just what you sent.

fills · every venue, one format

kalshi · fed dec cut 25 · yesfilled100 @ 0.42 · fee $1.71$43.71

positions · balances

kalshi · fed dec cut 25yes 100cash left on kalshi$956.29

result · after fees

if yes wins+$56.29if no wins−$43.71

illustrative

05 test

“Can I try it before I risk real money?”

Paper trade against real order books with fake money. Record every tick from the venues’ live streams and replay it. The same strategy code runs in backtest, paper and live.

python

# paper: real order books, fake money
client = Client()

# record every tick from the venues' live streams
record_stream(
    ["<slug>", "<KALSHI-TICKER>"],
    "ticks.jsonl",
)

# backtest: replay what you recorded
client = Client(mode="backtest", books=load_books("ticks.jsonl"))

# live: real money, the same strategy code
client = Client(mode="live", kalshi=Kalshi.from_env())

built for ai agents

Let an agent trade without giving it a blank check.

Every order is checked against limits you set before it goes out. Preview any order first. The agent can stop itself, but only a person can turn it back on.

Max position per market and total budgetMax daily lossAllowed markets onlyAsk a person above a size you pickStop-loss and take-profitKill switch

your accounts, your keys

Your money never passes through Layer.

Layer works with your own venue accounts. Your keys stay on your machine, and orders go straight from your code to the venue. Layer’s hosted service answers the questions that need a view across every venue, like which markets are the same bet.

How Layer works →

layer hostedmatching only

↕

your code + python sdkkeys stay here

↓ orders↓ orders

kalshi

polymarket us

markets

Prediction markets first. More markets next.

today

Kalshi · Polymarket USLIVE

next

More prediction markets, then crypto, equities and futures

for developers

Built for your code, and for your coding agent.

sdkPython

apiREST and webhooks

modesBacktest, paper and live

testingPaper mode on real books (both venues), plus Kalshi’s demo exchange

COMING NEXTTypeScript SDKMore venuesMCP server

Spend your time on the strategy.

Layer handles the venues, from finding the same bet to knowing what filled.

来源:Hacker News · uselayer.sh