Quote & simulate¶
The oracle-free pricing calls (quote_swap, simulate_swap, spot_price) move no funds and don't need a login — use them to size a trade and derive slippage protection before you swap. The one exception is oracle_price, which fetches a signed price from the backend and does need a logged-in session.
Which price call to use¶
First classify the symbol — the pricing path differs:
pd.instrument_kind("AMMT1") # "amm" -> pool-priced, 24/7
pd.instrument_kind("AAPL") # "oracle" -> oracle-priced, US market hours
| Symbol kind | Price with | Notes |
|---|---|---|
amm |
quote_swap, simulate_swap, spot_price |
Real pool pricing |
oracle |
oracle_price |
A reference USD price; quote_swap/spot_price don't apply |
Quote a swap (oracle-free)¶
from decimal import Decimal
from primedelta import SwapSide
quote = pd.quote_swap("AMMT1", SwapSide.STABLECOIN_TO_STOCK, Decimal("10"), exact="input")
exact="input"— "I'm spending this much, how much do I get?"exact="output"— "I want this much out, how much will it cost?"
Turn a quote into a minimum-out with slippage protection:
min_out_from_quote is a static helper: quote * (10000 - slippage_bps) / 10000. Never pass a slippage_bps that yields a zero floor — the raw SDK submits a zero-floor swap with no protection (it doesn't reject it for you; only the MCP server does).
Simulate (oracle-free)¶
For a full preview in one call:
sim = pd.simulate_swap("AMMT1", SwapSide.STABLECOIN_TO_STOCK, Decimal("10"), slippage_bps=100)
sim.expected_amount_out # Decimal
sim.min_amount_out # Decimal
sim.spot_price # Decimal
sim.fee_tier # int
simulate_swap returns a SwapSimulation with symbol, side, amount_in, expected_amount_out, min_amount_out, slippage_bps, spot_price, and fee_tier.
Spot price (oracle-free)¶
Oracle price (stocks)¶
Oracle-priced tokens have no pool quote — read the reference price and compute your minimum-out yourself, widening slippage to cover the pool's dynamic fee:
if pd.is_market_open():
ref = pd.oracle_price("AAPL") # reference USD price
# derive min_amount_out from ref with extra slippage, then swap
oracle_price is a reference price, not fee-adjusted, and it expires — act promptly.
Next → Place a swap