Quickstart
A sandbox key to a settled trade. Every call below is the real partner contract: run them against the host issued to you and you get the responses shown.
Import the API into Postman. The environment holds the variables to fill in: your host, your sandbox key and a test player id.
Postman collectionSandbox environmentThe one thing to get right
- 1Key
- 2Events
- 3Quote
- 4Reserve
- 5Order
- 6Position
- 7Exit
- 8Settle
- 9Reconcile
You own your customers’ cash ledger
Parity never holds a player's funds. Every money-moving response carries the exact amount to apply against your own ledger: reserve authorizationAmount, debit actualDebit, release releaseAmount, credit sellProceeds on an exit and settlementCredit on a resolution.
Apply those figures as given. If you recompute one from a price and a quantity, your books and Parity's can disagree.
Amounts inside those objects are exact decimal strings. The numbers beside them (stake, notional, platformFee, averagePrice) are for display.
1. Get a sandbox key
Parity issues you a sandbox operator key and shows it once. Sandbox keys start pk_test_ and live keys sk_live_. The mode belongs to your tenant, not to anything you send.
export PARITY_BASE="https://<issued-to-you>"
export PARITY_KEY="pk_test_..." # operator credential, shown once
export PARITY_USER="player-8421" # YOUR id for this playerimport { ParityClient } from './parity-sdk'; // the client Parity provides
const parity = new ParityClient({
baseUrl: process.env.PARITY_BASE!,
apiKey: process.env.PARITY_KEY!,
});
const player = parity.forUser(process.env.PARITY_USER!);- The key identifies the operator.
X-Parity-Useridentifies the end user and is required on every quote and order. There is no session and no login call. - A player is created the first time you name one on a write; reads never create one. On the settlement register and the reconciliation feed, a mistyped id returns
404 unknown_user. The order and position lists return an empty page instead, so check the id before trusting an empty result.
2. List events
GET /api/v1/events is the partner catalogue: one row per question, with its outcomes. You quote against an outcome's opaque ctr_… contract id, not the event id.
curl -s "$PARITY_BASE/api/v1/events?limit=1&tradable=true" \
-H "Authorization: Bearer $PARITY_KEY"// GET /api/v1/events [Authorization]
import { ParityClient } from './parity-sdk';
const parity = new ParityClient({
baseUrl: process.env.PARITY_BASE!,
apiKey: process.env.PARITY_KEY!,
});
const page = await parity.listEvents({ limit: 1, tradable: true });import os
import requests
response = requests.get(
f"{os.environ['PARITY_BASE']}/api/v1/events?limit=1&tradable=true",
headers={
"Authorization": f"Bearer {os.environ['PARITY_KEY']}",
},
)
print(response.status_code, response.json())using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get,
$"{Environment.GetEnvironmentVariable("PARITY_BASE")}/api/v1/events?limit=1&tradable=true");
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {Environment.GetEnvironmentVariable("PARITY_KEY")}");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php
$ch = curl_init(getenv('PARITY_BASE') . '/api/v1/events?limit=1&tradable=true');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('PARITY_KEY'),
],
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $response, PHP_EOL;{
"data": [
{
"id": "evt_...",
"slug": "fed-decision-in-september",
"title": "Fed Decision in September?",
"category": "economy",
"kind": "mutually_exclusive",
"imageUrl": "/api/v1/images/evt_...",
"outcomes": [
{
"id": "ctr_9f2b...",
"label": "No change",
"probability": 0.715,
"yesCents": 71.5,
"executableYesCents": 72,
"executableNoCents": 29,
"spreadCents": 1,
"tradable": true,
"closesAt": "2026-09-16T00:00:00.000Z"
}
]
}
],
"pagination": { "limit": 1, "total": 3751, "nextCursor": "…", "hasMore": true }
}yesCents is a probability. executableYesCents is a price.
yesCents is the market's reference, usually a midpoint nobody trades at. A buy takes the ask and a sell takes the bid. Across 22,586 open contracts the ask sits a median 1.5¢ above the reference and 24.8% differ by more than 10¢, so a ticket showing yesCents shows a price the player will not pay.
When executableYesCents is null, Parity has no usable book side: show “no price” and never fall back to the reference. The contract may still trade: five-minute crypto contracts are always null here and are priced from the live order book by POST /quotes.
const page = await parity.listEvents({ tradable: true, limit: 1 });
const outcome = page.items
.flatMap((e) => e.outcomes)
.find((o) => o.executableYesCents !== null)!;3. Quote $25
A quote fixes contract, side, price, fee and quantity for 30 seconds, and the order is checked against it. Five-minute crypto contracts hold for 5 seconds because their book moves faster. Read expiresAt instead of running your own timer.
curl -s -X POST "$PARITY_BASE/api/v1/quotes" \
-H "Authorization: Bearer $PARITY_KEY" \
-H "X-Parity-User: $PARITY_USER" \
-H "content-type: application/json" \
-d '{"marketId":"ctr_9f2b...","side":"YES","stake":25}'// POST /api/v1/quotes [Authorization, X-Parity-User, content-type]
import { ParityClient } from './parity-sdk';
const parity = new ParityClient({
baseUrl: process.env.PARITY_BASE!,
apiKey: process.env.PARITY_KEY!,
});
const quote = await parity.forUser(process.env.PARITY_USER!).quoteBuy({ contractId: 'ctr_9f2b...', side: 'YES', stake: 25 });import os
import requests
response = requests.post(
f"{os.environ['PARITY_BASE']}/api/v1/quotes",
headers={
"Authorization": f"Bearer {os.environ['PARITY_KEY']}",
"X-Parity-User": os.environ["PARITY_USER"],
"content-type": "application/json",
},
data='{"marketId":"ctr_9f2b...","side":"YES","stake":25}',
)
print(response.status_code, response.json())using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post,
$"{Environment.GetEnvironmentVariable("PARITY_BASE")}/api/v1/quotes");
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {Environment.GetEnvironmentVariable("PARITY_KEY")}");
request.Headers.TryAddWithoutValidation("X-Parity-User", Environment.GetEnvironmentVariable("PARITY_USER"));
request.Content = new StringContent("""{"marketId":"ctr_9f2b...","side":"YES","stake":25}""");
request.Content.Headers.Remove("content-type");
request.Content.Headers.TryAddWithoutValidation("content-type", "application/json");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php
$ch = curl_init(getenv('PARITY_BASE') . '/api/v1/quotes');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('PARITY_KEY'),
'X-Parity-User: ' . getenv('PARITY_USER'),
'content-type: application/json',
],
CURLOPT_POSTFIELDS => '{"marketId":"ctr_9f2b...","side":"YES","stake":25}',
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $response, PHP_EOL;{
"quoteId": "fc3be731-98dc-4c03-80ac-23576a708d9c",
"contractId": "ctr_9f2b...",
"side": "YES",
"action": "buy",
"executionPrice": 0.72,
"priceBasis": "book",
"stake": 25,
"platformFee": 0.3,
"platformFeeBps": 120,
"tradeAmount": 24.7,
"contracts": 34.3056,
"potentialPayout": 34.31,
"expiresAt": "2026-08-21T04:44:02.120Z",
"simulated": true,
"freshness": { "level": "fresh", "ageSeconds": 2, "feed": "websocket" },
"routing": { "consideredVenues": 1, "routable": false },
"operatorMoney": {
"currency": "USD",
"authorizationAmount": "25.00",
"actualDebit": "25.00",
"releaseAmount": "0.00",
"tradeAmount": "24.70",
"platformFee": "0.30",
"operatorFee": "0.00",
"venueFee": "0.00",
"venueFeeKnown": false
},
"operatorExitMoney": null
}The fee comes off the stake first ($25.00 − $0.30 = $24.70), the remainder buys contracts at executionPrice ($24.70 ÷ 0.72 = 34.31 contracts), and each contract settles at $1.00 if the side is right. Every figure is on the response, so you derive nothing.
const quote = await player.quoteBuy({ contractId: outcome.id, side: 'YES', stake: 25 });
// Show the player quote.executionPrice, not outcome.probability.4. Reserve $25 in your own ledger
Reserve before the order. authorizationAmount is the gross cash the player commits, fee included, so it is exactly what you hold.
const reservation = await wallet.reserve(quote.operatorMoney!.authorizationAmount);
// "25.00" is an exact decimal string. Parse it as a decimal, never as a float.Derive the clientOrderId from the reservation
Not from a clock or a random value. clientOrderId is the idempotency key, so it must be rebuildable from something you already stored if a crash loses our response.
This quickstart holds first and names the hold on the order with reserveReference, which clears the order to execute in the same call. You can also record the order first, then hold and confirm it: both orderings are supported, and The reserve handshake describes each.
5. Submit the order
curl -s -X POST "$PARITY_BASE/api/v1/orders" \
-H "Authorization: Bearer $PARITY_KEY" \
-H "X-Parity-User: $PARITY_USER" \
-H "content-type: application/json" \
-d '{"quoteId":"fc3be731-...","clientOrderId":"res-9031","reserveReference":"res-9031"}'// POST /api/v1/orders [Authorization, X-Parity-User, content-type]
import { ParityClient } from './parity-sdk';
const parity = new ParityClient({
baseUrl: process.env.PARITY_BASE!,
apiKey: process.env.PARITY_KEY!,
});
const order = await parity.forUser(process.env.PARITY_USER!).submitOrder({ quoteId: 'fc3be731-...', clientOrderId: 'res-9031', reserveReference: 'res-9031' });import os
import requests
response = requests.post(
f"{os.environ['PARITY_BASE']}/api/v1/orders",
headers={
"Authorization": f"Bearer {os.environ['PARITY_KEY']}",
"X-Parity-User": os.environ["PARITY_USER"],
"content-type": "application/json",
},
data='{"quoteId":"fc3be731-...","clientOrderId":"res-9031","reserveReference":"res-9031"}',
)
print(response.status_code, response.json())using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post,
$"{Environment.GetEnvironmentVariable("PARITY_BASE")}/api/v1/orders");
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {Environment.GetEnvironmentVariable("PARITY_KEY")}");
request.Headers.TryAddWithoutValidation("X-Parity-User", Environment.GetEnvironmentVariable("PARITY_USER"));
request.Content = new StringContent("""{"quoteId":"fc3be731-...","clientOrderId":"res-9031","reserveReference":"res-9031"}""");
request.Content.Headers.Remove("content-type");
request.Content.Headers.TryAddWithoutValidation("content-type", "application/json");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php
$ch = curl_init(getenv('PARITY_BASE') . '/api/v1/orders');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('PARITY_KEY'),
'X-Parity-User: ' . getenv('PARITY_USER'),
'content-type: application/json',
],
CURLOPT_POSTFIELDS => '{"quoteId":"fc3be731-...","clientOrderId":"res-9031","reserveReference":"res-9031"}',
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $response, PHP_EOL;{
"orderId": "3dd27f36-7780-4aa7-8af2-1a6854fbf8cb",
"clientOrderId": "res-9031",
"status": "filled",
"contractId": "ctr_9f2b...",
"side": "YES",
"action": "buy",
"filledQuantity": 34.3056,
"averagePrice": 0.72,
"notional": 24.7,
"stake": 25,
"rejectReason": null,
"simulated": true,
"idempotentReplay": false,
"routing": { "reason": "only_venue", "consideredVenues": 1 },
"operatorMoney": {
"authorizationAmount": "25.00",
"actualDebit": "25.00",
"releaseAmount": "0.00",
"tradeAmount": "24.70",
"platformFee": "0.30",
"operatorFee": "0.00",
"venueFee": "0.00",
"venueFeeKnown": false,
"currency": "USD"
},
"operatorExitMoney": null
}Apply the exact amounts, once they are final
// The hold is placed already, so naming it clears the order to execute in this call.
const placed = await player.submitOrder({
quoteId: quote.quoteId,
clientOrderId: reservation.id,
reserveReference: reservation.id,
});
const order = await player.getOrder(placed.orderId); // carries settlementState
if (order.settlementState === 'settled') {
// Keyed on the order, so a retry or a webhook for the same order books nothing twice.
await wallet.debit(order.operatorMoney!.actualDebit, order.orderId); // "25.00"
await wallet.release(order.operatorMoney!.releaseAmount, order.orderId); // "0.00" here
} else {
// Not final yet: keep holding the whole authorization.
// Apply both amounts once GET /api/v1/orders/{id} reads settled, or a webhook with final: true arrives.
await recheckLater(order.orderId);
}Apply the money only when the order is settled
With a live key the order comes back pending_venue_execution (or reserve_pending, if you leave out reserveReference) with an actualDebit of 0.00 and the whole authorization as releaseAmount, because nothing has been decided yet. Releasing that would hand back the hold behind an order that is about to be sent. Apply the money only when settlementState is settled. See The reserve handshake.
If the order is refused before it is recorded (409 quote_expired, price_stale, price_moved or price_unverified, or a 400 or 422 that names what to fix), no order was created: re-quote, and keep or release your own hold as your flow decides. A timeout or 409 reconciliation_required is not a refusal; see below.
- On a partial fill the release is non-zero: a venue that took $12.30 of a $25.00 authorization leaves $12.70 to hand back. Both identities hold exactly:
authorizationAmount = actualDebit + releaseAmountandactualDebit = tradeAmount + platformFee + operatorFee + venueFee. 201created this order.200withidempotentReplay: truereplayed one you already had. Retrying with the sameclientOrderIdis safe and never opens a second position.409 quote_expiredor409 price_stale: re-quote and let the player confirm the new price. Do not resend the same body or re-price for them.
409 reconciliation_required is not a rejection
The venue has not answered yet, so Parity cannot say whether the order is live. Collateral stays committed and you keep holding the authorization. Releasing could leave a real position with no cash behind it.
Recover with one call: find the order with GET /api/v1/orders?externalUserId=&clientOrderId=, using your own id, and act when its settlementState reads settled. The list row carries settlementState, transmissionState and, on this lookup, the order's intent; GET /api/v1/orders/{id} returns the same figures.
6. Read the position
curl -s "$PARITY_BASE/api/v1/positions?status=open&externalUserId=$PARITY_USER" \
-H "Authorization: Bearer $PARITY_KEY"// GET /api/v1/positions [Authorization]
import { ParityClient } from './parity-sdk';
const parity = new ParityClient({
baseUrl: process.env.PARITY_BASE!,
apiKey: process.env.PARITY_KEY!,
});
const page = await parity.listPositions({ status: 'open', externalUserId: process.env.PARITY_USER! });import os
import requests
response = requests.get(
f"{os.environ['PARITY_BASE']}/api/v1/positions?status=open&externalUserId={os.environ['PARITY_USER']}",
headers={
"Authorization": f"Bearer {os.environ['PARITY_KEY']}",
},
)
print(response.status_code, response.json())using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get,
$"{Environment.GetEnvironmentVariable("PARITY_BASE")}/api/v1/positions?status=open&externalUserId={Environment.GetEnvironmentVariable("PARITY_USER")}");
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {Environment.GetEnvironmentVariable("PARITY_KEY")}");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php
$ch = curl_init(getenv('PARITY_BASE') . '/api/v1/positions?status=open&externalUserId=' . getenv('PARITY_USER'));
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('PARITY_KEY'),
],
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $response, PHP_EOL;{
"positions": [
{
"positionId": "5e0c2a91-…",
"externalUserId": "player-8421",
"contractId": "ctr_9f2b...",
"side": "YES",
"status": "open",
"quantity": 34.3056,
"averagePrice": 0.72,
"openedAt": "2026-08-21T04:43:40.282Z",
"updatedAt": "2026-08-21T04:43:40.282Z",
"operatorMoney": { "currency": "USD", "costBasis": "24.70", "realisedPnl": "0.00" }
}
],
"count": 1,
"nextCursor": null,
"hasMore": false
}operatorMoney here carries facts, not instructions: cash already spent on what is still held, and profit already booked on what was closed. Amounts to move live on the order and the settlement, so you never book the same dollar from two places.
There is no mark-to-market: a value from the current bid would change between identical calls, and a ledger cannot reconcile against that. For the exit value, quote a sell.
7. Sell half of it
An exit is sized in contracts. A cash-sized sell cannot express “close this out”, because inverting the fee rounding either oversells or leaves a fraction.
curl -s -X POST "$PARITY_BASE/api/v1/quotes" \
-H "Authorization: Bearer $PARITY_KEY" \
-H "X-Parity-User: $PARITY_USER" \
-H "content-type: application/json" \
-d '{"marketId":"ctr_9f2b...","side":"YES","action":"sell","contracts":17.15}'// POST /api/v1/quotes [Authorization, X-Parity-User, content-type]
import { ParityClient } from './parity-sdk';
const parity = new ParityClient({
baseUrl: process.env.PARITY_BASE!,
apiKey: process.env.PARITY_KEY!,
});
const exitQuote = await parity.forUser(process.env.PARITY_USER!).quoteSell({ contractId: 'ctr_9f2b...', side: 'YES', contracts: 17.15 });import os
import requests
response = requests.post(
f"{os.environ['PARITY_BASE']}/api/v1/quotes",
headers={
"Authorization": f"Bearer {os.environ['PARITY_KEY']}",
"X-Parity-User": os.environ["PARITY_USER"],
"content-type": "application/json",
},
data='{"marketId":"ctr_9f2b...","side":"YES","action":"sell","contracts":17.15}',
)
print(response.status_code, response.json())using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post,
$"{Environment.GetEnvironmentVariable("PARITY_BASE")}/api/v1/quotes");
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {Environment.GetEnvironmentVariable("PARITY_KEY")}");
request.Headers.TryAddWithoutValidation("X-Parity-User", Environment.GetEnvironmentVariable("PARITY_USER"));
request.Content = new StringContent("""{"marketId":"ctr_9f2b...","side":"YES","action":"sell","contracts":17.15}""");
request.Content.Headers.Remove("content-type");
request.Content.Headers.TryAddWithoutValidation("content-type", "application/json");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php
$ch = curl_init(getenv('PARITY_BASE') . '/api/v1/quotes');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('PARITY_KEY'),
'X-Parity-User: ' . getenv('PARITY_USER'),
'content-type: application/json',
],
CURLOPT_POSTFIELDS => '{"marketId":"ctr_9f2b...","side":"YES","action":"sell","contracts":17.15}',
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $response, PHP_EOL;const exitQuote = await player.quoteSell({
contractId: held.contractId,
side: held.side,
contracts: held.quantity / 2,
});
const exit = await player.submitOrder({
quoteId: exitQuote.quoteId,
clientOrderId: `exit-${reservation.id}`,
});
// A sell CREDITS, once it is final. operatorMoney is null on an exit, deliberately.
const sold = await player.getOrder(exit.orderId);
if (sold.settlementState === 'settled') {
await wallet.credit(sold.operatorExitMoney!.sellProceeds, sold.orderId);
} else {
await recheckLater(sold.orderId); // live: credit when it reads settled
}{
"action": "sell",
"operatorMoney": null,
"operatorExitMoney": {
"currency": "USD",
"sellProceeds": "12.20",
"platformFee": "0.15",
"venueFee": "0.00",
"venueFeeKnown": false
}
}sellProceeds is already net
The fees beside it show the player what the round trip cost; do not subtract them again. operatorMoney is null here so a wallet cannot debit a player for selling their own position.
Read the position again: quantity has shrunk and realisedPnl has moved. The remainder is still open.
8. Credit the settlement
When the contract resolves, Parity writes one settlement per position with the amount to credit already computed.
curl -s "$PARITY_BASE/api/v1/settlements?limit=100" \
-H "Authorization: Bearer $PARITY_KEY"// GET /api/v1/settlements [Authorization]
import { ParityClient } from './parity-sdk';
const parity = new ParityClient({
baseUrl: process.env.PARITY_BASE!,
apiKey: process.env.PARITY_KEY!,
});
const page = await parity.listSettlements({ limit: 100 });import os
import requests
response = requests.get(
f"{os.environ['PARITY_BASE']}/api/v1/settlements?limit=100",
headers={
"Authorization": f"Bearer {os.environ['PARITY_KEY']}",
},
)
print(response.status_code, response.json())using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get,
$"{Environment.GetEnvironmentVariable("PARITY_BASE")}/api/v1/settlements?limit=100");
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {Environment.GetEnvironmentVariable("PARITY_KEY")}");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php
$ch = curl_init(getenv('PARITY_BASE') . '/api/v1/settlements?limit=100');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('PARITY_KEY'),
],
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $response, PHP_EOL;{
"settlements": [
{
"id": "a41f7d0e-…",
"positionId": "5e0c2a91-…",
"externalUserId": "player-8421",
"contractId": "ctr_9f2b...",
"side": "YES",
"resolution": "YES",
"outcome": "won",
"contracts": 17.15,
"realisedPnl": 4.8,
"lifetimeRealisedPnl": 5.9,
"settledAt": "2026-08-22T18:02:11.004Z",
"operatorMoney": {
"currency": "USD",
"settlementCredit": "17.15",
"voidCredit": "0.00"
},
"cursor": "…"
}
],
"count": 1,
"nextCursor": "…", // stays set at the tail: a watermark to poll with
"hasMore": false // the terminator
}let cursor = await store.readSettlementCursor(); // undefined on the first run
for await (const s of parity.iterateSettlements({ cursor })) {
if (s.outcome === 'won') await wallet.credit(s.operatorMoney.settlementCredit, s.id);
if (s.outcome === 'void') await wallet.refund(s.operatorMoney.voidCredit, s.id);
cursor = s.cursor;
await store.writeSettlementCursor(cursor); // only once it is applied
}Resume from the cursor, not from a time
A settlement is listed once its write has committed, and its settledAt is stamped before that. A poll for “settled since my last run” can therefore step past one that committed late and never see it. The cursor cannot: it waits for late writes and resumes exactly where you stopped. settledFrom and settledTo are filters for a report, not a place to resume.
- Exactly one of the two is non-zero; a loss zeroes both. Winnings and a refund are separate fields because most ledgers book them differently.
- Key your credit on the settlement
id. It is stable, so your consumer can safely run twice after a crash. realisedPnlis this settlement's figure;lifetimeRealisedPnlis the position's running total. They differ when the position was partly exited, as yours was.
9. Reconcile
curl -s "$PARITY_BASE/api/v1/reconciliation" \
-H "Authorization: Bearer $PARITY_KEY"// GET /api/v1/reconciliation [Authorization]
import { ParityClient } from './parity-sdk';
const parity = new ParityClient({
baseUrl: process.env.PARITY_BASE!,
apiKey: process.env.PARITY_KEY!,
});
const report = await parity.reconciliationReport();import os
import requests
response = requests.get(
f"{os.environ['PARITY_BASE']}/api/v1/reconciliation",
headers={
"Authorization": f"Bearer {os.environ['PARITY_KEY']}",
},
)
print(response.status_code, response.json())using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get,
$"{Environment.GetEnvironmentVariable("PARITY_BASE")}/api/v1/reconciliation");
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {Environment.GetEnvironmentVariable("PARITY_KEY")}");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");<?php
$ch = curl_init(getenv('PARITY_BASE') . '/api/v1/reconciliation');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('PARITY_KEY'),
],
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $response, PHP_EOL;const report = await parity.reconciliationReport();
if (!report.ok) escalate(report.findings);
// And the fact stream your own books are rebuilt from:
for await (const fact of parity.iterateFeed({ cursor: storedCursor })) {
await apply(fact); // idempotent on fact.id
storedCursor = fact.cursor; // advance only once applied
}Reading the feed does not consume it: the same cursor always returns the same items, so a consumer that stops mid-batch just reads again. Details are on Reconciliation.
You are integrated when
- Your ticket shows the quote's
executionPrice, never the reference. - You reserve
authorizationAmount, debitactualDebitand releasereleaseAmountoncesettlementStateissettled, and never recompute any of them. - An exit credits
sellProceedswithout subtracting the fees again. - Your error handling branches on
error: a409price refusal re-quotes, and a409 reconciliation_requiredor a timeout holds and polls. - Your order retries reuse the same
clientOrderId. - Your settlement consumer keys on the settlement
id, resumes from its storedcursor, and can run twice safely. - Parity's conformance runner, provided on request, passes against your own sandbox key (
--base $PARITY_BASE --key $PARITY_KEY). It places and sells orders, so it refuses to run with a live key unless you add--read-only.