An iOS app that turns option prices and Greeks into interactive 3D surfaces in augmented reality.
If you would like a TestFlight build or a deeper dive into the ML/Quant/AR design feel free to reach out to: 815-616-7848 or rheats2@illinois.edu
AR Greeks Lab visualizes the Black–Scholes world as something you can walk around.
Given user‑selected option parameters, the app:
- Computes option price and Greeks across a grid of underlying prices and expiries.
- Normalizes those values into heights and builds a 3D mesh.
- Anchors that mesh onto a detected real‑world surface via ARKit.
- Lets the user explore the surface spatially and inspect exact numbers by tapping.
The goal is an educational, intuition‑building tool that feels like an internal prototype from a quant / risk team, not a retail trading product.
- European call/put pricing using the Black–Scholes closed‑form solution.
- Analytic Greeks implemented in Swift:
- Price
- Delta
- Gamma
- (Theta, Vega, Rho implemented in the quant module for future use.)
- Dynamic surface generation over:
- Spot price range, e.g.
0.5×S₀ … 1.5×S₀ - Time to expiry range, e.g.
0.01 … T_maxyears
- Spot price range, e.g.
- Tunable resolution (default 40×40 grid) balancing smoothness and mobile performance.
- World tracking and horizontal plane detection (tables, floors).
- Realistic environment lighting via environment texturing.
- Custom mesh generation from height maps:
- Converts a 2D grid of
Doublevalues into a dense triangle mesh. - Scales surfaces to ~0.6 m × 0.6 m for comfortable viewing in AR.
- Converts a 2D grid of
- Surfaces are anchored slightly above the detected plane to avoid z‑fighting/clipping.
-
Long‑press on a detected plane
→ Generates and places a surface at that location (or moves it). -
Tap on the existing surface
→ Converts the 3D hit position back into grid indices, then displays:- Spot price (S)
- Time to expiry (T)
- Price
- Delta
- Gamma
-
Mode picker
→ Switch between visualizing:- Price surface
- Delta surface
- Gamma surface
-
Baseline + comparison:
- Save Baseline captures the current surface (mode + parameters) as a reference grid.
- Compare toggle enables a second, red surface representing
current − baseline, placed beside the main one. - This reveals how regime changes (e.g., volatility spikes, time decay) deform the pricing / Greek landscape.
- Instruction bar at the top:
- “Long‑press to place a surface. Tap the surface to inspect a point.”
- Compact overlay card showing last inspected point:
S,T,Price,Delta,Gamma
- Bottom control panel:
- Sliders for Spot, Volatility (σ), and Time horizon (T_max)
- Mode picker (Price / Delta / Gamma)
- Buttons:
- Save Baseline
- Compare toggle
- Reset (clears all anchors and selection)
- About screen:
- Explains the quant engine and planned ML component.
- Provides user‑facing debugging tips, e.g.:
- Move the device over textured surfaces to help plane detection.
- Use Reset if tracking feels off.
- Distinguish long‑press (place) vs tap (inspect).
- Language: Swift
- UI: SwiftUI
- AR / 3D: ARKit + RealityKit
- State / Data Flow: MVVM style with
ObservableObjectand@Published
-
OptionModels.swiftOptionType(.call,.put)OptionParametersdescribing:- Spot
S, StrikeK, TimeT - Volatility
σ, Risk‑free rater, Dividend yieldq
- Spot
Quantstruct:- Standard normal PDF / CDF implementations
- Black–Scholes pricing (
price(...)) for calls/puts - Analytic Greeks:
delta,gamma,theta,vega,rho
-
SurfaceGrid.swiftSurfaceModeenum:.price,.delta,.gammaSurfaceGrid.generate(...):- Builds evenly spaced axes for S and T.
- Evaluates
Quantat each grid node for the desired quantity.
-
SurfaceViewModel.swift- Acts as the central state container:
- Parameters:
spot,strike,timeMax,volatility,rate,dividend,optionType - Visualization:
mode(SurfaceMode),comparisonEnabled - Baseline: stored
SurfaceGridfor comparison - Selection (overlay):
selectedS,selectedTselectedPrice,selectedDelta,selectedGamma
- Parameters:
- Responsible for:
- Generating
SurfaceData(heights + axes) from model parameters - Normalizing surfaces for AR scale
- Computing difference surfaces (
current − baseline) - Updating selection from grid indices
- Resetting selection & broadcasting reset events to AR
- Generating
- Acts as the central state container:
-
ARViewContainer.swiftUIViewRepresentablebridge from SwiftUI to RealityKit.- Configures AR session:
ARWorldTrackingConfigurationwith horizontal plane detection
- Handles gestures:
UILongPressGestureRecognizer→ triggersplaceSurface(...)UITapGestureRecognizer→ hit‑tests mesh for inspection
- Manages:
- AR anchors and their lifetime
- Main surface
ModelEntity(blue) - Optional difference surface
ModelEntity(red)
- Converts tap‑hit positions from local coordinates to grid indices based on:
- Known mesh width/depth
- Grid resolution
- Stored axes (
sAxis,tAxis)
-
ContentView.swift- Layout:
- Instruction + overlay at top
- Full‑screen AR view behind
- Control panel at bottom
- Binds sliders, toggles, and buttons directly to
SurfaceViewModelstate.
- Layout:
-
AboutView.swift- SwiftUI sheet describing:
- High‑level Black–Scholes explanation
- What Price / Delta / Gamma mean intuitively
- Planned ML approximation extension
- Troubleshooting steps for AR
- SwiftUI sheet describing:
Model: Black–Scholes for European options.
Inputs:
- Spot price (S)
- Strike price (K)
- Time to expiry (T) (years)
- Volatility (\sigma)
- Risk‑free rate (r)
- Dividend yield (q)
- Option type: Call / Put
Key intermediate terms:
[ d_1 = \frac{\ln(S / K) + (r - q + 0.5\sigma^2)T}{\sigma \sqrt{T}}, \quad d_2 = d_1 - \sigma\sqrt{T} ]
Call price:
[ C = S e^{-qT} N(d_1) - K e^{-rT} N(d_2) ]
Put price:
[ P = K e^{-rT} N(-d_2) - S e^{-qT} N(-d_1) ]
where (N(\cdot)) is the standard normal CDF.
Greeks implemented:
- Delta: sensitivity of price to spot changes.
- Gamma: sensitivity of delta to spot changes (curvature).
- Theta, Vega, Rho: implemented for completeness; currently not surfaced as separate AR modes.
All formulas are implemented directly in Swift for full control and interview‑friendly discussion.
The project is intentionally structured to support a machine‑learning approximator:
- Generate a synthetic dataset using the analytic Black–Scholes engine:
- Inputs: ((S, K, T, \sigma, r, q, \text{type}))
- Targets: price or a Greek (e.g., delta).
- Train a small MLP (e.g., in Python) to approximate price / delta on this domain.
- Export the trained model’s weights and integrate an on‑device forward pass.
- Add a UI toggle:
- Analytic vs Neural Net surface.
- Visualize approximation error via:
- Difference surfaces
- Error overlays
- Error metrics displayed when tapping points.
This gives a strong story around:
- Using ML to approximate PDE solutions.
- Speed vs accuracy and model risk.
- Integrating ML into a mobile AR visualization pipeline.
- Move your phone to let ARKit detect a horizontal plane
- Note: textured surfaces help with tracking horizontal planes
- Long-press on the plane to place the surface
- A blue 3D surface will appear anchored to the plane
- Adjust parameters via the bottom sliders
- Switch mode (price/delta/gamma) to see different visualizations
- Tap on surface to show grid position, price, delta, and gamma at specific grid position
- Comparison mode:
- Configure parameters and press save baseline
- Change parameters
- Toggle compare ON
- Long press again to place red comparative surface
-
Reset when:
- Tracking feels off
- Scene is cluttered
- User desires a clean AR session
-
Check out About section (top-right):
- Provides a quick explanation of the math, ML usage/future plans, and debugging tips
Current Limitations:
- Supports European options-pricing only (no America/early-logic)
- Surfaces are generated from a single volatility value (no full volatility surface)
- ML approximation is architected but not yet integrated in this public version
- No persistence layer; settings are reset between app launches
Future Work:
- Add on‑device ML approximator for price / delta and analytic vs neural comparison
- Add more surface modes (Theta, Vega, Rho)
- Export screenshots or simple PDF reports of surfaces and inspected points
- Add presets for common underlyings (e.g., SPX, AAPL) and maturities
- Explore more advanced models (local vol, stochastic vol) for richer surfaces.