Skip to main content

Equity Curve

GET /v1/account/equity
Returns hourly portfolio value snapshots for equity curve charting and performance analysis.

Authentication

API key only — X-API-Key: <key> (or the PM-compat POLY_API_KEY / Authorization: Bearer ps_live_... aliases). A Supabase Bearer JWT is not accepted here.

Query Parameters

ParameterTypeDefaultDescription
daysint7Days of history (1–90)
wallet_idstringapiall (every wallet you own), api (your API wallet), or an integer wallet id you own (404 WALLET_NOT_FOUND otherwise) — see Wallets → Scoping account reads. Omit to default to your API wallet (legacy wallet_id IS NULL snapshots are folded in so pre-multi-wallet history stays continuous; with no active API wallet only the legacy bucket is returned).

Request

# Last 7 days of hourly data (default)
curl -H "X-API-Key: $API_KEY" \
  "https://api.polysimulator.com/v1/account/equity"

# Last 30 days
curl -H "X-API-Key: $API_KEY" \
  "https://api.polysimulator.com/v1/account/equity?days=30"

Response

Snapshots are returned in chronological (ascending) order — oldest first, newest last — so you can plot the array as-is.
[
  {
    "timestamp": "2026-02-06T10:00:00Z",
    "cash_balance": "9993.50",
    "position_value": "6.30",
    "total_value": "9999.80",
    "pnl": "-0.20"
  },
  {
    "timestamp": "2026-02-06T11:00:00Z",
    "cash_balance": "9993.50",
    "position_value": "7.00",
    "total_value": "10000.50",
    "pnl": "0.50"
  }
]
FieldTypeDescription
timestampstringISO-8601 UTC snapshot time (rounded to the hour)
cash_balancestringCash balance at this timestamp
position_valuestringTotal market value of positions at this timestamp
total_valuestringcash_balance + position_value at this timestamp
pnlstringProfit & loss relative to the wallet’s starting balance (API wallet by default)

Charting Example

import requests, os
import matplotlib.pyplot as plt
from datetime import datetime

BASE_URL = os.environ["POLYSIM_BASE_URL"]
headers = {"X-API-Key": os.environ["POLYSIM_API_KEY"]}

equity = requests.get(
    f"{BASE_URL}/v1/account/equity",
    headers=headers,
    params={"days": 30},  # 30 days
).json()

times = [datetime.fromisoformat(e["timestamp"]) for e in equity]
values = [float(e["total_value"]) for e in equity]

plt.figure(figsize=(12, 6))
plt.plot(times, values)
# Starting balance = your API-wallet baseline, NOT the $1,000 UI MAIN
# wallet: Pro = 10_000, Pro+ = 25_000 (Free keys are read-only). Set it
# to your tier's baseline so the reference line is meaningful.
API_WALLET_BASELINE = 10_000  # Pro; use 25_000 on Pro+
plt.axhline(y=API_WALLET_BASELINE, color="gray", linestyle="--", label="Starting balance")
plt.title("Portfolio Equity Curve")
plt.ylabel("Portfolio Value ($)")
plt.legend()
plt.show()

Errors

All errors return {"error": "<CODE>", "message": "<human-readable>"}.
Statuserror codeWhen
401MISSING_API_KEYNo API key header supplied
401INVALID_KEYAPI key is unknown, deactivated, or expired
404WALLET_NOT_FOUNDwallet_id is not owned by the caller

Next Steps

  • Balance — Current balance snapshot
  • Portfolio — Complete portfolio overview