This commit is contained in:
@@ -175,115 +175,6 @@ namespace MarketData.Numerical
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
// assuming that the list is in descending date order
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Fetch the first price of the month for both the asset and the benchmark, allowing both to walk forward in the month by up to 10 days until we get a good price
|
||||
/// </summary>
|
||||
/// <param name="symbol"></param>
|
||||
/// <param name="benchmark"></param>
|
||||
/// <param name="requestedDate"></param>
|
||||
/// <param name="symbolPricesByDate"></param>
|
||||
/// <param name="benchmarkPricesByDate"></param>
|
||||
/// <returns></returns>
|
||||
//private static BetaPrice GetPrice(String symbol, String benchmark, DateTime requestedDate, Dictionary<DateTime, Price> symbolPricesByDate, Dictionary<DateTime, Price> benchmarkPricesByDate)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// int maxAdvanceDays = 10;
|
||||
// Price symbolPrice = default;
|
||||
// Price benchmarkPrice = default;
|
||||
|
||||
// for (int advanceDays = 0; advanceDays < maxAdvanceDays; advanceDays++)
|
||||
// {
|
||||
// if (!symbolPricesByDate.ContainsKey(requestedDate))
|
||||
// {
|
||||
// requestedDate = requestedDate.AddDays(1);
|
||||
// continue;
|
||||
// }
|
||||
// symbolPrice = symbolPricesByDate[requestedDate];
|
||||
|
||||
// if (!benchmarkPricesByDate.ContainsKey(requestedDate))
|
||||
// {
|
||||
// requestedDate = requestedDate.AddDays(1);
|
||||
// continue;
|
||||
// }
|
||||
// benchmarkPrice = benchmarkPricesByDate[requestedDate];
|
||||
// if(null != symbolPrice && null != benchmarkPrice)break;
|
||||
// }
|
||||
|
||||
// if (null == symbolPrice || null == benchmarkPrice) return null;
|
||||
|
||||
// symbolPrice.Date = requestedDate.Date;
|
||||
// benchmarkPrice.Date = requestedDate.Date;
|
||||
// return new BetaPrice(symbol, benchmark, symbolPrice, benchmarkPrice, requestedDate);
|
||||
// }
|
||||
// catch (Exception exception)
|
||||
// {
|
||||
// MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Exception:{0}", exception.ToString()));
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//public static double Beta(String symbol,DateTime asof,int months=36)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// String benchmark = "SPY";
|
||||
// DateGenerator dateGenerator = new DateGenerator();
|
||||
|
||||
// BetaPrices betaPrices = new BetaPrices();
|
||||
// DateTime startDate = dateGenerator.GetPrevMonthStart(asof);
|
||||
// DateTime minPricingDate = PricingDA.GetEarliestDate(symbol);
|
||||
// Dictionary<DateTime, Price> symbolPricesByDate = new Dictionary<DateTime, Price>();
|
||||
// Dictionary<DateTime, Price> benchmarkPricesByDate = new Dictionary<DateTime, Price>();
|
||||
// List<DateTime> historicalDates = new List<DateTime>();
|
||||
|
||||
// while (historicalDates.Count < (months + 1))
|
||||
// {
|
||||
// historicalDates.Add(startDate);
|
||||
// startDate = dateGenerator.GetPrevMonthStart(startDate);
|
||||
// }
|
||||
// DateTime earliestDate = historicalDates[historicalDates.Count - 1];
|
||||
|
||||
// Prices symbolPrices = PricingDA.GetPrices(symbol, asof, earliestDate);
|
||||
// Prices benchmarkPrices = PricingDA.GetPrices(benchmark, asof, earliestDate);
|
||||
|
||||
// foreach (Price price in symbolPrices) symbolPricesByDate.Add(price.Date, price);
|
||||
// foreach (Price price in benchmarkPrices) benchmarkPricesByDate.Add(price.Date, price);
|
||||
|
||||
// startDate = dateGenerator.GetPrevMonthStart(asof);
|
||||
|
||||
// while (betaPrices.Count < (months + 1))
|
||||
// {
|
||||
// BetaPrice betaPrice = GetPrice(symbol, benchmark, startDate, symbolPricesByDate, benchmarkPricesByDate);
|
||||
// if (null == betaPrice)
|
||||
// {
|
||||
// MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Beta({0},{1}).. Cannot calculate Beta. Missing price on {2}",symbol,Utility.DateTimeToStringMMHDDHYYYY(asof),Utility.DateTimeToStringMMHDDHYYYY(startDate)));
|
||||
// return double.NaN;
|
||||
// }
|
||||
// betaPrices.Add(betaPrice);
|
||||
// startDate = dateGenerator.GetPrevMonthStart(startDate);
|
||||
// if (startDate < minPricingDate) break;
|
||||
// }
|
||||
|
||||
// double[] returnsSymbol = betaPrices.ReturnsSymbol();
|
||||
// double[] returnsBenchmark = betaPrices.ReturnsBenchmark();
|
||||
// double beta = Numerics.Beta(ref returnsSymbol, ref returnsBenchmark);
|
||||
// return beta;
|
||||
// }
|
||||
// catch (Exception exception)
|
||||
// {
|
||||
// MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Exception:{0}",exception.ToString()));
|
||||
// return double.NaN;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ using MarketData.MarketDataModel;
|
||||
namespace MarketData.Numerical
|
||||
{
|
||||
/// <summary>
|
||||
/// Black Sholes Option Pricing Model for simplest scenario
|
||||
/// Black Sholes Option Pricing Model for simplest scenario.
|
||||
/// This is an adoption of the Abramowitz Stegun approximation for the cumulative normal distribution
|
||||
/// </summary>
|
||||
public class BlackScholesOptionPricingModel
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user