@polyedge/client
v0.1.0
Published
Compute prediction-market edges locally: PolyEdge fair values plus your own venue order book, on your machine.
Maintainers
Readme
@polyedge/client
Compute prediction-market edges on your own machine.
PolyEdge publishes the fair value: an outcome probability de-vigged from sportsbook consensus. You hold the other half, an order book from your own venue account. This package does the subtraction.
npm i @polyedge/client @polyedge/resolverimport { PolyEdge } from '@polyedge/client';
const pe = new PolyEdge({ apiKey: process.env.POLYEDGE_KEY });
const fairValues = await pe.fairValues({ league: 'nba' }); // ours, over HTTP
const settlementRules = await pe.settlementRules(); // ours
const books = await yourKalshiClient.books(); // yours, never sent to us
const edges = pe.computeEdges({ fairValues, books, settlementRules, sizeUsd: 1000 });A worked end-to-end board is in
examples/kalshi-board.
Why it runs locally
PolyEdge holds no data agreement with Polymarket or Kalshi, and both prohibit us from collecting their prices or redistributing them, derived forms included. You are permitted to read your own account: Kalshi's Developer Agreement allows a member to use the API for their own trading.
So the edge is computed where the permission is. Your credentials, positions and
order flow never reach us. The only outbound call to PolyEdge is a GET for fair
values.
This is not a reduced version of a hosted product. buildEdge here is the same
function the hosted board ran, and a snapshot built from published inputs plus
your own book is byte-identical to one the server produced, down to
provenance.inputsHash.
What it refuses to do
The refusal rules matter more than the happy path, because this runs against real money.
- A fair value PolyEdge refused to publish produces no edge. It never falls back to the venue's own mid, which would be circular and would read as an edge of zero.
- An unknown fee leaves
netnull, never zero. Zero is a claim that trading is free. - A market whose venue settles a tie differently from a book is blocked, not adjusted with a fudge factor. There is no defensible comparison between a two-way book price and a contract that settles on a different event.
- A book with no matching fair value is skipped, not priced against nothing.
- The market price is the executable ask, never the mid. You cannot buy at a midpoint, and a wide book makes a mid-based edge fiction.
Fees
feeModelFor(book) builds the model from what the venue reported. Kalshi's taker
fee is roundUpToCent(0.07 x C x P x (1-P)), rounded on the total rather than per
contract. Polymarket's comes from that market's own feesEnabled and
takerBaseFee; fees on with an unreadable rate returns null, because unknown is
not free.
Verify against a live order ticket before trading real size.
MIT. Part of PolyEdge.
