Options

The Options category contains helper methods you can use for trading options.

Remarks

CreateSyntheticOption

CreateSyntheticOption

Bars CreateSyntheticOption(DateTime startDate, DateTime expiryDate, double strikePrice, bool isCallOption);
Bars CreateSyntheticOption(int asOfBar, int atLeastXDaysTilExpiration, int daysToPlotBeforeCreation, bool isCallOption);

Creates and returns a Bars object for a synthetic option contract of the symbol currently being processed with the specified parameters: 

The boolean parameter isCallOption specifies whether the option will be a call (true) or a put (false) contract.  The resulting Bars object's symbol has the following components: !_symbol_strike_YYMMDD_optionType, where YYMMDD is the monthly expiry and type is either CALL or PUT

Remarks

Note: Live options trading is not supported by Wealth-Lab. This method returns hypothetical data.

Disclaimer: Backtesting provides a hypothetical calculation of how a security or portfolio of securities, subject to a trading strategy, would have performed over a historical time period. You should not assume that backtesting of a trading strategy will provide any indication of how your portfolio of securities, or a new portfolio of securities, might perform over time. You should choose your own trading strategies based on your particular objectives and risk tolerances. Be sure to review your decisions periodically to make sure they are still consistent with your goals. Past performance is no guarantee of future results.


Example

protected override void Execute(){
            ChartPane optionPane = CreatePane(50, true, true);
            
            for(int bar = 30; bar < Bars.Count; bar++)
            {
                if (IsLastPositionActive)
                {
                    if( CumUp.Value( bar, Close, 1 ) >= 2 )
                    {
                        // Sell the call
                        Bars contract = LastPosition.Bars;
                        SetContext( contract );
                        SellAtMarket( bar+1, LastPosition, "Sell call" );
                        RestoreContext();                    
                    }
                }
                else
                {
                    if( CumDown.Value( bar, Close, 1 ) >= 4 )
                    {
                        // Buy the call contract that has at least 30 days to expiry. 
                        Bars contract = CreateSyntheticOption( bar, 30, 30, true );
                        SetContext( contract );
                        BuyAtMarket( bar+1, "Buy call" );
                        RestoreContext();
                        
                        // Plot it if we haven't done so already
                        Color c = Color.FromArgb(255, 128, 128);
                        PlotSymbol(optionPane, contract, c, c);
                    }
                }
            }
        }
    }
}
BuyAtMarket

IsOptionExpiryDate

bool IsOptionExpiryDate(int bar);
DateTime NextOptionExpiryDate(int bar);

Returns true if the specified bar falls on an options expiration date.  Options expiration dates typically fall on the third Friday of every month.  If that particular Friday falls on a holiday that the market is closed on, the following market day is the options expiration date.


Example

protected override void Execute(){    
// Annotate Option Expiry Dates on the Chart
    
    for(int bar = 1; bar < Bars.Count; bar++)
    {
        if ( IsOptionExpiryDate( bar ) )
        {
            DrawCircle( PricePane, 4, bar, Open[bar], Color.Navy, Color.Navy, WealthLab.LineStyle.Solid, 1, false  ); 
            DrawCircle( PricePane, 4, bar, Close[bar], Color.Blue, Color.Blue, WealthLab.LineStyle.Solid, 1, true  ); 
        }

    }
}
BuyAtMarket

NextOptionExpiryDate

DateTime NextOptionExpiryDate(int bar);
DateTime NextOptionExpiryDate(DateTime dt);

Returns DateTime of the closest options expiration date as of the specified bar.  Options expiration dates typically fall on the third Friday of every month.  If that particular Friday falls on a holiday that the market is closed on, the following market day is the options expiration date.


Example

protected override void Execute(){// Show next option expiration date    
            DateTime nextExpiry = NextOptionExpiryDate(Bars.Count-1);
            DrawLabel(PricePane, "Next options expiration date falls on " + nextExpiry.Date.ToShortDateString());
        }
    }
}