Skip to content

Guides Guides

P/L graphs

POST /calculate returns the grid behind the calculator's chart: profit or loss for a range of stock prices on each date up to expiry.

Request a grid

Same body as /pop, plus an optional price range and volatility shift. It counts as 2 requests.

curl -X POST https://www.optionsprofitcalculator.com/api/v1/calculate \
  -H "Authorization: Bearer $OPC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "symbol": "AAPL",
    "legs": [
      {"type": "call", "action": "buy", "strike": 345, "expiry": "2026-12-18"},
      {"type": "call", "action": "sell", "strike": 360, "expiry": "2026-12-18"}
    ],
    "priceMin": 320,
    "priceMax": 380
  }'

The grid

  • graph.prices: the stock prices (columns).
  • graph.dates: the dates (rows), each with daysFromToday and atExpiry. The first row isn't necessarily today; the last is the earliest expiry.
  • graph.profitLoss[d][p]: dollars if you close at prices[p] on dates[d].
  • graph.expiry.profitLoss: the expiry row on its own, for a classic payoff diagram.

Chart it

A heatmap of profitLoss (green for profit, red for loss) looks like the calculator's table. A line chart of graph.expiry.profitLoss against graph.prices is the payoff at expiry.

Python
import matplotlib.pyplot as plt

g = data["graph"]
plt.plot(g["prices"], g["expiry"]["profitLoss"], label="At expiry")
plt.plot(g["prices"], g["profitLoss"][0], label=g["dates"][0]["date"])
plt.axhline(0, color="grey", linewidth=0.5)
plt.xlabel("Stock price")
plt.ylabel("Profit / loss ($)")
plt.legend()
plt.show()

What-if volatility

Set ivChange to shift every leg's implied volatility, e.g. -10 to see the effect of a volatility crush after earnings.