Expression Variables
Complete reference of available data variables
Expression Variables Reference
When building custom expressions in GreeksLab, you have access to a comprehensive set of variables representing real-time market data, position information, and portfolio metrics. This reference covers all available variables you can use in your custom conditions and rolling expressions.
Variable Categories
Variables are organized into categories based on their scope and purpose:
- Leg Variables: Data specific to individual option legs
- Position Variables: Aggregated data for entire positions
- Market Variables: Real-time market and underlying data
- Time Variables: Trading time and schedule information
- Economic Variables: Economic events and indicators
Variable Naming Convention
Variables in GreeksLab follow a consistent naming pattern:
- Leg Variables:
Leg Name {Variable Name}
(e.g.,Leg Delta
) - Position Variables:
Position Name {Variable Name}
(e.g.,Position PnL, USD
) - Global Variables:
{Variable Name}
(e.g.,Minutes Since Market Open
,Day of the Week
)
Leg Variables
Variables that provide data about individual option legs within your positions.
Position and Sizing
Leg Position
- Description: Number of contracts for this leg (positive for long, negative for short)
- Type: Integer
- Example: -2 (short 2 contracts), 1 (long 1 contract)
- Use Cases: Position sizing calculations, risk scaling
Option Details
Leg Option Strike
- Description: Strike price of the option
- Type: Float
- Example: 4500.0, 4525.0
- Use Cases: Strike relationship analysis, spread width calculations
Financial Metrics
Leg Total Fees
- Description: Total commissions and fees paid for this leg
- Type: Float
- Example: 2.50 (total fees for the leg)
- Use Cases: Fee impact analysis, profitability calculations
Leg Average Cost
- Description: Average cost basis per contract for the leg
- Type: Float
- Example: 12.50 (average premium paid/received per contract)
- Use Cases: Cost basis analysis, profit calculations
Leg Initial Premium
- Description: Initial premium collected/paid when leg was opened
- Type: Float
- Example: -125.0 (premium collected), 87.5 (premium paid)
- Use Cases: Initial premium comparisons, percentage-based exits
Leg Total Premium
- Description: Total premium for all contracts in the leg
- Type: Float
- Example: -250.0 (2 contracts × -125 premium each)
- Use Cases: Total position premium calculations
Leg Market Value
- Description: Current market value of the leg
- Type: Float
- Example: -150.0 (current value for short leg)
- Use Cases: Mark-to-market valuation, real-time pricing
Leg PnL, USD
- Description: Current profit/loss for the leg in USD
- Type: Float
- Example: 75.0 (profit), -125.0 (loss)
- Use Cases: Individual leg P&L tracking, leg-specific exits
Greeks and Risk Metrics
Leg Delta
- Description: Option delta (price sensitivity to underlying movement)
- Type: Float
- Range: -1.0 to 1.0
- Example: 0.16 (16 delta), -0.30 (-30 delta for short position)
- Use Cases: Directional risk analysis, delta-neutral adjustments
Leg Portfolio Delta
- Description: Position delta (option delta × position size × 100)
- Type: Float
- Example: -32.0 (short 2 contracts of 16-delta option)
- Use Cases: Portfolio delta calculations, hedge ratios
Status and Activity
Leg Is Open
- Description: Current status of the leg
- Type: Boolean
- Values: true (open), false (closed/expired)
- Use Cases: Status-based conditional logic, lifecycle management
Leg Number of Rolls
- Description: Number of times this leg has been rolled
- Type: Integer
- Example: 0 (never rolled), 2 (rolled twice)
- Use Cases: Roll frequency analysis, adjustment limits
Performance Tracking
Leg PnL, % of the Initial Premium
- Description: P&L as percentage of initial premium
- Type: Float
- Example: 50.0 (50% profit), -200.0 (200% loss)
- Use Cases: Percentage-based profit/loss rules
Leg Cumulative Max PnL, USD
- Description: Highest P&L achieved by this leg during its lifetime
- Type: Float
- Use Cases: Trailing stop implementations, high-water mark tracking
Leg Cumulative Min PnL, USD
- Description: Lowest P&L experienced by this leg during its lifetime
- Type: Float
- Use Cases: Maximum loss tracking, recovery analysis
Leg PnL, USD, Gross
- Description: Gross P&L before fees and commissions
- Type: Float
- Use Cases: Fee impact analysis, gross return calculations
Position Variables
Variables that provide aggregated data for entire positions (all legs combined).
Financial Performance
Position PnL, USD
- Description: Total position profit/loss in USD
- Type: Float
- Example: 125.50 (profit), -200.0 (loss)
- Use Cases: Position-level profit targets, stop losses
Position Portfolio Delta
- Description: Net delta exposure for the entire position
- Type: Float
- Example: -15.5 (net short delta), 0.0 (delta neutral)
- Use Cases: Delta-neutral strategies, directional risk management
Position Market Value
- Description: Current total market value of all legs
- Type: Float
- Use Cases: Mark-to-market position valuation
Position Total Fees
- Description: Total fees and commissions for the position
- Type: Float
- Use Cases: Fee impact analysis, net profit calculations
Status and Composition
Position Is Open
- Description: Overall position status
- Type: Boolean
- Values: true (open), false (closed)
- Use Cases: Position lifecycle management
Position Initial Premium
- Description: Net premium collected/paid when position opened
- Type: Float
- Example: -150.0 (net credit), 200.0 (net debit)
- Use Cases: Premium-based percentage calculations
Position Total Premium
- Description: Current total premium value of all legs
- Type: Float
- Use Cases: Total position value tracking
Position Number of Open Legs
- Description: Number of legs currently open in the position
- Type: Integer
- Example: 4 (iron condor), 2 (spread), 1 (single leg)
- Use Cases: Position complexity analysis, partial close tracking
Greeks and Risk
Position Weighted Delta
- Description: Weighted delta of the position
- Type: Float
- Use Cases: Alternative delta calculation method
Position Total Number of Rolls
- Description: Total number of rolls executed across all legs
- Type: Integer
- Use Cases: Adjustment frequency analysis, maximum adjustment limits
Performance Tracking
Position PnL, % of the Initial Premium
- Description: Position P&L as percentage of initial net premium
- Type: Float
- Example: 50.0 (50% of premium collected)
- Use Cases: Percentage-based position management
Position Cumulative Max PnL, USD
- Description: Highest P&L achieved during position lifetime
- Type: Float
- Use Cases: Trailing stops, high-water mark analysis
Position Cumulative Min PnL, USD
- Description: Lowest P&L experienced during position lifetime
- Type: Float
- Use Cases: Maximum drawdown tracking, recovery analysis
Position Time in Position (minutes)
- Description: Number of minutes the position has been open
- Type: Integer
- Example: 120 (2 hours), 1440 (24 hours)
- Use Cases: Time-based management, holding period analysis
Position PnL, USD, Gross
- Description: Gross position P&L before fees
- Type: Float
- Use Cases: Fee impact analysis
Market Context at Entry
Position VIX at Position Open
- Description: VIX level when the position was opened
- Type: Float
- Example: 18.5, 32.7
- Use Cases: Entry conditions analysis, volatility regime tracking
Position SPX at Position Open
- Description: SPX price when the position was opened
- Type: Float
- Example: 4500.0
- Use Cases: Underlying movement analysis, entry level tracking
Market Variables
Real-time market data and underlying asset information.
Account-Level Data
Account Day PnL, USD
- Description: Total account P&L across all positions
- Type: Float
- Use Cases: Portfolio-level risk management, account protection
Account Equity
- Description: Current account equity (cash + position values)
- Type: Float
- Use Cases: Position sizing based on account size, risk percentage calculations
Account Total Fees
- Description: Total fees paid across all positions
- Type: Float
- Use Cases: Fee impact analysis, cost tracking
Underlying Price Data
SPX Minute Open Price
- Description: SPX opening price for the current minute
- Type: Float
- Use Cases: Minute-level price analysis
SPX Current Quote Close
- Description: SPX current/closing price
- Type: Float
- Use Cases: Current price comparisons, profit/loss calculations
Underlying Movement and Gaps
SPX Gap Move, USD
- Description: Dollar gap from previous day's close to today's open
- Type: Float
- Example: 25.0 (gap up 15.50)
- Use Cases: Gap-based entry/exit rules, overnight risk analysis
SPX Intraday Move %
- Description: Percentage gap from previous close
- Type: Float
- Example: 0.55 (0.55% gap up), -0.35 (-0.35% gap down)
- Use Cases: Percentage-based gap analysis
SPX Intraday Move, USD
- Description: Dollar move from today's open to current price
- Type: Float
- Example: 30.0 (up 20 from open)
- Use Cases: Intraday momentum analysis, trend following
SPX Intraday Move %
- Description: Percentage move from today's open
- Type: Float
- Example: 0.67 (up 0.67% from open)
- Use Cases: Percentage-based momentum rules
SPX Day High
- Description: Highest price reached from market open to current time
- Type: Float
- Use Cases: Intraday high tracking, breakout analysis
SPX Day Low
- Description: Lowest price reached from market open to current time
- Type: Float
- Use Cases: Intraday low tracking, support analysis
SPX Day Open
- Description: Official opening price for the trading day
- Type: Float
- Use Cases: Opening price reference, gap calculations
Volatility Data (VIX)
VIX Current Quote Close
- Description: Current VIX level
- Type: Float
- Example: 18.5, 32.7
- Use Cases: Volatility-based strategy selection, fear/greed analysis
VIX Gap Move, USD
- Description: VIX gap in points from previous close
- Type: Float
- Example: 2.5 (VIX up 2.5 points), -1.8 (VIX down 1.8 points)
- Use Cases: Volatility gap analysis, overnight sentiment shifts
VIX Intraday Move %
- Description: VIX percentage gap from previous close
- Type: Float
- Use Cases: Relative volatility gap analysis
VIX Intraday Move, USD
- Description: VIX change in points from today's open
- Type: Float
- Use Cases: Intraday volatility trend analysis
VIX Intraday Move %
- Description: VIX percentage change from today's open
- Type: Float
- Use Cases: Relative volatility movement analysis
Options Market Data
SPX ATM Straddle Premium, USD
- Description: Premium of at-the-money straddle (call + put)
- Type: Float
- Example: 28.50, 45.75
- Use Cases: Direct volatility measurement, premium richness analysis
For individual options (when referenced in expressions):
Option Current Quote Mid
- Description: Mid-market quote for specific option
- Type: Float
- Use Cases: Fair value analysis, bid-ask spread considerations
Option Delta
- Description: Delta of specific option
- Type: Float
- Use Cases: Individual option risk analysis
Time Variables
Trading time and schedule information.
Minutes Since Market Open
- Description: Minutes since market open (9:30 AM ET)
- Type: Integer
- Example: 0 (market open), 60 (10:30 AM), 390 (market close)
- Use Cases: Time-based entry/exit rules, intraday timing
Day of the Week
- Description: Day of the week as integer
- Type: Integer
- Values: 0 (Monday), 1 (Tuesday), 2 (Wednesday), 3 (Thursday), 4 (Friday)
- Use Cases: Day-of-week effects, weekly patterns
Economic Variables
Economic events and indicators that might affect trading.
FED Release Day
- Description: Whether today is a Federal Reserve decision day
- Type: Boolean
- Values: true (Fed day), false (regular day)
- Use Cases: Avoid trading on high-impact days, event-based strategies
Next Steps
Now that you understand all available variables, learn how to combine them into powerful custom expressions:
- Custom Expressions - Build complex trading logic using these variables
- Rules Overview - Apply variables in trading rules and conditions
- Roll Leg Action - Use variables for intelligent position adjustments
- Actions Overview - Understand how variables work with different actions
The variable system in GreeksLab gives you complete access to all market and position data, enabling sophisticated trading strategies that react to real-time market conditions with precision.