Skip to main content
The shape of it: rest a bid on a few venues, and the moment one gets hit, sell the same size across the deepest venues you have. You earn the spread; SORY finds the best place to take the other side. Everything here uses one client, because it is one symbol.

Why it is only this long

The order updates itself

order.filled is live. You hold the object place() gave you and read it — no lookup, no bookkeeping.

The hedge picks its own venue

A market order across HEDGE_ON walks the merged book and takes the cheapest liquidity, wherever it is.

Fees are in the comparison

fee_offset on the hedge venues means “cheapest” accounts for what each one charges you.

The quote is priced off the hedge

book.vwap(size, side, exclude=...) prices the clip on the venues that would actually fill it, so the edge you quote is the edge you can lay off.

Silence is not a miss

confirm() asks the venues before you retry. A hedge re-sent because its fill was reported late is a position twice over.

Dead venues drop out

A venue that stops publishing leaves the book on its own, so the hedge never routes into a stale price.
Keep the two sets apart. If you rest a bid on a venue and then send a sell there, you can trade against yourself. Some venues prevent it on the same account and some do not, so the reliable fix is the one above: hedge only on venues you are not quoting on.Overlapping them is fine only if you have confirmed that venue’s self-trade prevention yourself.

Picking up after a restart

SORY keeps nothing on disk. Ask the venues what you still have working:
Cancel them and re-quote, or adopt them — either way you are looking at the truth rather than a file that might be stale.

Before you point it at real money

Pass dry_run=True on every place() above. Each one runs the whole path — routing the hedge, per-venue rounding, building the orders — and sends nothing. Watch the printed hedges for a while first.
Quotes rest until they are filled or cancelled. There is no post-only, so a quote placed inside the spread can cross and pay taker — price it outside the touch, as EDGE_BPS does above, and it will not.