public System.Collections.Generic.List<DataFeed> GetDataFeed(PricingLibrary.FinancialProducts.IOption option, System.DateTime fromDate) { System.Collections.Generic.List<DataFeed> result = new System.Collections.Generic.List<DataFeed>() ; using (DataBaseDataContext mtdc = new DataBaseDataContext()) { var result1 = (from s in mtdc.HistoricalShareValues where ((option.UnderlyingShareIds.Contains(s.id)) && (s.date >= fromDate)&&(s.date<=option.Maturity)) select s).OrderByDescending(d => d.date).ToList(); System.DateTime curentdate = result1[result1.Count() - 1].date; System.Collections.Generic.Dictionary<String, decimal> priceList = new System.Collections.Generic.Dictionary<String, decimal>(); for (int i = result1.Count() - 1; i >= 0 ; i--) { if (result1[i].date==curentdate) { priceList.Add(result1[i].id.Trim(), result1[i].value); } else { DataFeed datafeed = new DataFeed(curentdate, priceList); result.Add(datafeed); curentdate = result1[i].date; priceList = new System.Collections.Generic.Dictionary<String, decimal>(); priceList.Add(result1[i].id.Trim(), result1[i].value); } if (i == 0) { DataFeed datafeedOut = new DataFeed(curentdate, priceList); result.Add(datafeedOut); } } return result; } }
// On initialise la classe public ShareHisto(System.DateTime startDate, System.DateTime maturityDate, PricingLibrary.FinancialProducts.IOption product) { this._Data = new List<PricingLibrary.Utilities.MarketDataFeed.DataFeed>(); this.startDate = startDate; this.maturityDate = maturityDate; this._product = product; }
// Permet de price un produit selon les paramètres d'entrée public PricingLibrary.Computations.PricingResults priceProduct(PricingLibrary.FinancialProducts.IOption Product, DateTime date, double[] spot, double[] volatility, bool simulated, double[,] correlationMatrix = null) { int nbDays = 0; if (simulated) { nbDays = 365; } else { nbDays = 250; } if (Product is PricingLibrary.FinancialProducts.VanillaCall) { return this.pricer.PriceCall((PricingLibrary.FinancialProducts.VanillaCall)Product, date, nbDays, spot[0], volatility[0]); } else { return this.pricer.PriceBasket((PricingLibrary.FinancialProducts.BasketOption)Product, date, nbDays, spot, volatility, correlationMatrix); } }
// Renvoie la liste des sous-jacents d'une option s'ils existent public System.Collections.Generic.List<PricingLibrary.FinancialProducts.Share> getUnderlyingShares(PricingLibrary.FinancialProducts.Option option) { System.Collections.Generic.List<PricingLibrary.FinancialProducts.Share> underlyingShares = new System.Collections.Generic.List<PricingLibrary.FinancialProducts.Share>(); System.Collections.Generic.Dictionary<String, String> UnderlyingSharesNames = new System.Collections.Generic.Dictionary<String, String>(); using (DataBaseDataContext mtdc = new DataBaseDataContext()) { UnderlyingSharesNames = (from s in mtdc.ShareNames where (option.UnderlyingShareIds.Contains(s.id)) select s).ToDictionary(s => s.name, s => s.id); } for (int index = 0; index < UnderlyingSharesNames.Count; index++) { var item = UnderlyingSharesNames.ElementAt(index); String itemKey = item.Key; String itemValue = item.Value.TrimEnd(); PricingLibrary.FinancialProducts.Share share = new PricingLibrary.FinancialProducts.Share(itemKey, itemValue); underlyingShares[index] = share; } return underlyingShares; }
public VanillaCompositionProvider(PricingLibrary.FinancialProducts.Option vanillaCall) { _option = (PricingLibrary.FinancialProducts.VanillaCall)vanillaCall; }
public BasketCompositionProvider(PricingLibrary.FinancialProducts.Option basketOption) { _option = (PricingLibrary.FinancialProducts.BasketOption)basketOption; }