- UID
- 2
- 积分
- 2874674
- 威望
- 1387366 布
- 龙e币
- 1487308 刀
- 在线时间
- 13156 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-11-24
|
【OptionsComplex】
- inputs:
- MyAssetType( numericsimple ),
- DaysLeft( numericsimple ),
- StrikePr( numericsimple ),
- AssetPr( numericsimple ),
- Rate100( numericsimple ),
- Yield100( numericsimple ),
- ForeignRate100( numericsimple ),
- Volty100( numericsimple ),
- PutCall( numericsimple ),
- EuroAmer01( numericsimple ),
- oOptPriceValue( numericref ),
- oDelta( numericref ),
- oGamma( numericref ),
- oVega( numericref ),
- oTheta( numericref ),
- oRho( numericref ) ;
- variables:
- var0( false ),
- var1( 0 ),
- var2( 0 ),
- var3( 0 ),
- var4( 0 ),
- var5( 0 ),
- var6( 0 ),
- var7( 0 ),
- var8( 0 ),
- var9( 0 ),
- var10( 0 ),
- var11( 0 ),
- var12( 0 ),
- var13( 0 ),
- var14( 0 ),
- var15( 0 ) ;
-
-
- var0 = ( MyAssetType <> 1 and MyAssetType <> 2 and MyAssetType <> 3 and
- MyAssetType <> 4 ) or StrikePr <= 0 or Volty100 <= 0 or ( PutCall <> 2 and
- PutCall <> 3 ) ;
- condition1 = var0 or AssetPr <= 0 or DaysLeft <= 0 ;
- if condition1 then
- begin
- oOptPriceValue = 0 ;
- oDelta = 0 ;
- oGamma = 0 ;
- oVega = 0 ;
- oTheta = 0 ;
- oRho = 0 ;
- if var0 = false then
- begin
- if DaysLeft <= 0 then
- begin
- if PutCall = 3 and StrikePr <= AssetPr then
- oDelta = 1
- else if PutCall = 2 and StrikePr >= AssetPr then
- oDelta = -1 ;
- oOptPriceValue = OS_Intrinsic( AssetPr, PutCall, StrikePr ) ;
- end ;
- if AssetPr = 0 and PutCall = 2 then
- oOptPriceValue = StrikePr ;
- end ;
- OptionsComplex = -1 ;
- end
- else
- begin
- var1 = Rate100 * 0.01 ;
- var3 = Yield100 * 0.01 ;
- var4 = ForeignRate100 * 0.01 ;
- if MyAssetType = 1 then
- var5 = var1
- else if MyAssetType = 2 then
- var5 = var1 - var3
- else if MyAssetType = 3 then
- var5 = 0
- else if MyAssetType = 4 then
- var5 = var1 - var4 ;
- var2 = Volty100 * 0.01 ;
- var6 = DaysLeft * 0.002739726027 ;
- var7 = SquareRoot( var6 ) ;
- var8 = var2 * var7 ;
- var9 = StrikePr * ExpValue( -var1 * var6 ) ;
- var10 = ExpValue( ( var5 - var1 ) * var6 ) ;
- var11 = ( Log( AssetPr / StrikePr ) + ( var5 + Power( var2, 2 ) / 2 ) * var6 )
- / var8 ;
- var12 = ExpValue( -Square( var11 ) * 0.5 ) * 0.398942280407 ;
- var13 = NormSCDensity( var11 ) ;
- var14 = var11 - var8 ;
- var15 = NormSCDensity( var14 ) ;
- if PutCall = 3 then
- begin
- oOptPriceValue = var13 * AssetPr * var10 - var15 * var9 ;
- oDelta = var13 * var10 ;
- oTheta = ( -var12 * AssetPr * var2 * var10 / ( 2 * var7 ) - var13
- * ( var5 - var1 ) * AssetPr * var10 - var15 * var1 * var9 )
- * 0.002739726027 ;
- oRho = var15 * var6 * var9 * 0.01 ;
- end
- else if PutCall = 2 then
- begin
- if EuroAmer01 = 0 then
- oOptPriceValue = ( var13 - 1 ) * AssetPr * var10 + ( 1 - var15 ) * var9
- else if EuroAmer01 = 1 then
- oOptPriceValue = BjerkStensCall( StrikePr, AssetPr, var6, var1 - var5,
- -var5, var2 ) ;
- oDelta = ( var13 - 1 ) * var10 ;
- oTheta = ( -var12 * AssetPr * var2 * var10 / ( 2 * var7 ) + ( 1 - var13 )
- * ( var5 - var1 ) * AssetPr * var10 + ( 1 - var15 ) * var1 * var9 )
- * 0.002739726027 ;
- oRho = ( var15 - 1 ) * var6 * var9 * 0.01 ;
- end ;
- oGamma = ( var12 * var10 ) / ( AssetPr * var8 ) ;
- oVega = var12 * AssetPr * var7 * var10 * 0.01 ;
- OptionsComplex = 1 ;
- end ;
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|