private Dictionary<System.DateTime, ResultValue> computeResults(Option option, HedgingPortfolio portfolio, CompositionProvider compositionProvider, List<DataFeed> dataFeedList, int windowLength, int nbDaysYear, bool isSimulated) { Dictionary<System.DateTime, ResultValue> plotResults = new Dictionary<System.DateTime, ResultValue>(); // Rebalancement du portfeuille au cours du temps double riskFreeRate = 0; for (int i = windowLength; i < dataFeedList.Count() - 2; i++) { // Calcul du taux sans risque proratisé riskFreeRate = Utilities.computeAccruedRiskFreeRate(dataFeedList[i].Date, dataFeedList[i + 1].Date, nbDaysYear, isSimulated); // Rebalancement et actualisation de la valeur du portefeuille PricingResults pricingResults = compositionProvider.getComposition(dataFeedList, dataFeedList[i].Date, windowLength, nbDaysYear); portfolio.update(dataFeedList[i].PriceList, pricingResults.Deltas, riskFreeRate); ResultValue curentValue = new ResultValue(pricingResults.Price, portfolio.Value); plotResults.Add(dataFeedList[i].Date, curentValue); } // Calcul du taux sans risque proratisé riskFreeRate = Utilities.computeAccruedRiskFreeRate(dataFeedList[dataFeedList.Count() - 2].Date, dataFeedList[dataFeedList.Count() - 1].Date, nbDaysYear, isSimulated); // Valeur finale du portefeuille portfolio.computeValue(dataFeedList[dataFeedList.Count() - 1].PriceList, riskFreeRate); ResultValue finalValue = new ResultValue(option.GetPayoff(dataFeedList.Last().PriceList), portfolio.Value); plotResults.Add(dataFeedList.Last().Date, finalValue); return plotResults; }
public void sharedMain(Option option, CompositionProvider compositionProvider, List<DataFeed> dataFeedList, List<Share> shareList, DateTime initialDate, double strike, DateTime maturity, int windowLength, int numberOfDaysPerYear, bool simulated) { PricingResults pricingResults = compositionProvider.getComposition(dataFeedList, initialDate, windowLength, numberOfDaysPerYear); HedgingPortfolio portfolio = createPortfolio(option, pricingResults, dataFeedList, initialDate); Dictionary<System.DateTime, ResultValue> plotResults = computeResults(option, portfolio, compositionProvider, dataFeedList, windowLength, numberOfDaysPerYear, !simulated); // Calcul du PayOff double payoff = option.GetPayoff(dataFeedList.Last().PriceList); Console.WriteLine(portfolio.Value); Console.WriteLine(payoff); // Création du graphique de résultats PlotModel = new PlotModel(); SetUpModel(); OptionDescription = "Underlying share: " + Utilities.shareListString(shareList.ToArray()) + "\n Strike: " + strike + "\n Start Date: " + initialDate + "\n Maturity: " + maturity; // Tracé du plot DrawPlot(plotResults, payoff); }