public enum CalcEx.CallPutFlag { Call, Put }; public static double BlackScholes(this double S, double X, double D, double R, double V, CallPutFlag flag)public enum CallPutFlag { Call, Put }; public static double BlackScholes(CallPutFlag flag, double S, double X, double D, double R, double V)
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using Community.Components;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { private string str (double s) { return String.Format("{0:0.00}", s); } protected override void Execute() { double price = Bars.Close[Bars.Count-1]; if( price < 10 ) Abort(); double call = price.BlackScholes( price + 5.0d, 60, 1d, 20.0, CalcEx.CallPutFlag.Call ); // days=60, rate=1%, volatility=20%=0.20 double put = price.BlackScholes( price - 5.0d, 60, 1d, 20.0, CalcEx.CallPutFlag.Put ); // days=60, rate=1%, volatility=20%=0.20 PrintDebug( string.Concat( "Call = ", str(call), " Put = ", str(put) ) ); } } }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using Community.Components;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { private string str (double s) { return String.Format("{0:0.00}", s); } protected override void Execute() { double price = Bars.Close[Bars.Count-1]; if( price < 10 ) Abort(); double call = Calculate.BlackScholes( Calculate.CallPutFlag.Call, price, price + 5.0d, 60, 1d, 20.0 ); // days=60, rate=1%, volatility=20%=0.20 double put = Calculate.BlackScholes( Calculate.CallPutFlag.Put, price, price - 5.0d, 60, 1d, 20.0 ); // days=60, rate=1%, volatility=20%=0.20 PrintDebug( string.Concat( "Call = ", str(call), " Put = ", str(put) ) ); } } }