Actions Overview
Actions define what happens when your rule conditions are satisfied. GreeksLab provides four powerful actions that give you complete control over position management throughout the trading lifecycle.
Understanding Actions
Actions are the "THEN" part of your rule logic. When all conditions in a rule are met, the specified action executes automatically during backtesting.
Action Formula: IF (conditions are met) THEN (execute action)
💡 Example:Rule Example:
- Conditions: Time = 9:31 AM AND VIX > 20
- Action: Open Position
- Result: New position created when both conditions are true
Available Actions
1. Open Position
Purpose: Creates a new position based on your position template
When to Use:
- Entry rules that initiate new trades
- Adding positions when market conditions are favorable
- Scaling into positions over time
How It Works:
- Uses your strategy's position template to determine legs
- Executes all legs of the position simultaneously
Parameters:
- Position Sizing — Controls how many contracts to open each time the action fires. See Position Sizing below for the three available modes (Fixed Multiplier, Fixed Premium, % of Account).
- Minimum Premium — The minimum premium per contract the position must collect to be opened, in dollars. The setting is ignored for positions opened for debit.
💡 Example:Open Position Action:
- Template: Iron Condor (4 legs)
- Triggers: At 9:31 AM when VIX > 20
- Result: Full Iron Condor position opened with all 4 legs
Position Sizing
Position sizing controls how many contracts (spreads) to open each time the Open Position action fires. Every leg's ratio is multiplied by the computed number of contracts, so the overall position shape is preserved — only the scale changes. GreeksLab supports three sizing modes:
Fixed Multiplier
Always open a fixed, predetermined number of contracts regardless of price or account size. Simple and deterministic — useful when you want complete control over exposure or when comparing strategies on an even footing.
- Contracts — Exact number of contracts to open (1–100). For multi-leg positions, this multiplies all legs proportionally.
Fixed Premium
Automatically calculate the number of contracts so the total premium is close to a target dollar amount. For credit strategies, this targets the credit received; for debit strategies, the premium paid. Keeps capital at risk roughly constant across different market regimes, even as option prices shift.
- Premium ($) — Target dollar amount per trade (1–1,000,000). The engine divides this by the cost of 1 contract at the moment of entry and rounds down (by default) to get the contract count.
- Open at least 1 contract — When enabled, the engine always opens at least 1 contract, even if the position premium exceeds your target. When disabled, the trade is skipped entirely if it's too expensive.
- Round to nearest — When enabled, the contract count is rounded to the nearest integer instead of always rounding down. Example: with a 5,000targetand2,501 per contract, rounding down gives 1 contract; rounding to nearest gives 2.
% of Account
Size the position as a percentage of your current account equity. The number of contracts is recalculated at the start of each trading day based on the latest equity value, so winners increase exposure and losers decrease it automatically (full Kelly-style compounding).
- Percentage — Percentage of account equity to allocate per trade (0.1%–100%). The engine calculates the contract count so the total premium equals this percentage of current equity.
- Open at least 1 contract — When enabled, the engine always opens at least 1 contract, even if the computed position exceeds the target allocation. When disabled, the trade is skipped if it's too expensive relative to current equity.
- Round to nearest — When enabled, the contract count is rounded to the nearest integer instead of rounding down.
⚠️ Important:% of Account mode processes trading days sequentially because each day's contract count depends on the previous day's closing equity. Backtests using this mode may run slightly slower than the other two modes, which can parallelize days.
💡 Example:Fixed Premium Example:
- Target Premium: $1,000 (credit)
- 1x position credit on entry day: $250
- Result: 4 contracts opened (1000 / 250)
% of Account Example:
- Percentage: 2%
- Account equity at start of day: $50,000 → target = $1,000
- 1x position cost on entry day: $400
- Result: 2 contracts opened (floor(1000 / 400))
Best Practices:
- Keep entry conditions specific but not overly restrictive
- Test position sizing thoroughly
- Consider market liquidity when timing entries
- Use time-based filters to avoid opening positions near market close
2. Close Position
Purpose: Exits an entire existing position by closing all legs
When to Use:
- Profit target management rules
- Stop loss protection rules
- Time-based exit rules
- Risk management scenarios
How It Works:
- Closes all legs of the selected position
- Executes market orders for immediate exit
- Calculates final P&L for the position
Parameters:
- Part to close - The part of the current position to close. If the resulting order is not a whole number of options, it will be rounded down to the nearest whole number.
💡 Example:Close Position Action:
- Trigger: Position profit >= $100 OR Position loss >= -$50
- Result: All legs of the position are closed immediately
- P&L: Final profit/loss is recorded
Best Practices:
- Set realistic profit targets based on historical performance
- Use time-based exits to avoid increasing gamma risk
- Consider market hours when setting exit conditions
3. Close Legs
Purpose: Selectively closes specific legs of a multi-leg position
When to Use:
- Partial profit taking strategies
- Risk reduction without full exit
- Converting multi-leg positions to simpler structures
- Managing individual leg performance
How It Works:
- You specify which legs to close
- Only selected legs are closed, others remain open
- Remaining legs continue to be managed by other rules
💡 Example:Close Legs Action:
- Position: Iron Condor (4 legs)
- Trigger: Short call leg shows 50% profit
- Action: Close legs 1 and 2 (call spread side)
- Result: Position becomes Iron Put spread
Best Practices:
- Use for profit-taking on profitable legs while keeping others
- Consider the resulting position structure after partial closure
- Plan follow-up rules for remaining legs
- Monitor Greeks changes after partial closure
4. Roll Leg
Purpose: Adjusts a specific position leg to a new strike
When to Use:
- Strike adjustments when position moves against you
- Converting losing positions to potentially profitable ones
Overview:
Roll Leg is the most advanced action, allowing you to modify existing position legs rather than simply opening or closing them.
Common Roll Scenarios:
- Strike Roll: Move a leg to a different strike price
💡 Example:Roll Leg Example:
- Position: Short Put at $100 strike and Short Call at $110 strike
- Market Movement: Stock drops to $100
- Roll Action: Roll call from $110 to $100 strike
- Result: Collect premium and reduce position delta
Basic Parameters:
- Leg to Roll: Which leg to roll
- Minimum Premium: Set the minimum premium per option contract (in dollars) that you want to collect when rolling the leg. This ensures you collect enough premium to justify the roll.
- Roll Target Variable: Choose what you want to control when rolling the leg.
- Target Expression: Create an expression that defines your rolling goal. Think of it as a math equation where your target variable is the unknown.
- Validation Constraints: Validation constraints prevent unwanted situations by checking leg strike relationships after the roll, such as potential inversions.
- Max Executions: Maximum number of times roll leg action can be executed
Learn more about rolling
Best Practices
General Action Guidelines
- Be Specific: Choose actions that match your exact intent
- Test Thoroughly: Validate action logic in backtesting before live trading
- Plan Sequences: Consider how actions interact with each other
- Monitor Greeks: Understand how actions affect position risk characteristics
Rule Interaction
⚠️ Important:Actions from different rules can affect the same position. Design rules carefully and set rule priorities to avoid conflicts.
Action Timing
- Entry Actions: Triggered once per position
- Management Actions: Some actions can trigger multiple times per position
Next Steps
Ready to implement specific actions? Explore these detailed guides:
Or return to the Strategy Building Guide to see how actions fit into your complete trading strategy.