Calculate Iron Condor MAX Gain in SQL Server

This is one of many functions used on MTR Investors Group to calculate option return values.
Create FUNCTION [dbo].[f_get_condor_gain_pct] 
(
 @SellStrike decimal(18,2),
 @BuyStrike decimal(18,2), 
 @PutSellPrice decimal(18,2),
 @PutBuyPrice decimal(18,2),
 @CallSellPrice decimal(18,2),
 @CallBuyPrice decimal(18,2)
)
RETURNS decimal(18,2)
AS
BEGIN
declare @GainAmount decimal(18,2);
declare @SpreadAmount decimal(18,2);

--The Option Sell > Buy - On Strikes the call side is flipped.
set @GainAmount = ((@PutSellPrice - @PutBuyPrice) + (@CallSellPrice - @CallBuyPrice)) * 100 ;
set @SpreadAmount = (@SellStrike - @BuyStrike) * 100;
if (@GainAmount = 0 or @SpreadAmount = 0) return 0;

return (@GainAmount / @SpreadAmount);

END
Comments are closed