Skip to main content

fetch_positions

async fn fetch_positions(
    market_id: Option<&str>,
) -> Result<Vec<Position>, OpenPxError>
Returns all open positions, optionally filtered to one market. See Position for fields. Convenience methods include cost_basis(), current_value(), unrealized_pnl(), and unrealized_pnl_percent().
let positions = ex.fetch_positions(None).await?;
for p in &positions {
    println!("{} {}: {} @ {}", p.market_id, p.outcome, p.size, p.average_price);
}

fetch_balance

async fn fetch_balance() -> Result<HashMap<String, f64>, OpenPxError>
Returns a map keyed by currency / token symbol (e.g. { "USD": 1234.56 } or { "USDC": 120.00 }).

fetch_balance_raw

async fn fetch_balance_raw() -> Result<serde_json::Value, OpenPxError>
Returns the unparsed JSON from the underlying balance endpoint. Useful when you need fields the unified surface doesn’t expose. Polymarket only — returns NotSupported on Kalshi.

refresh_balance

async fn refresh_balance() -> Result<(), OpenPxError>
Forces a refetch of cached balance / allowance state. No-op on exchanges that don’t cache. Polymarket uses this to refresh USDC and CTF allowances after on-chain approvals.