public override CompletePricingResults getPricingResults(List <DataFeed> pricingData) { double[,] underlyingSpots = ConvertDecimalArray.listDataFeedToDoubleArray(pricingData); double[] volatility = StatComputing.volatilitiesComputing(underlyingSpots); Pricer pricer = new Pricer(); double spot = underlyingSpots[underlyingSpots.GetLength(0) - 1, 0]; PricingResults pricingResults = pricer.Price((VanillaCall)opt, pricingData.Last().Date, 365, spot, volatility.First()); CompletePricingResults completePricingResults = new CompletePricingResults(pricingResults, new double[] { spot }); return(completePricingResults); }
public override CompletePricingResults getPricingResults(List <DataFeed> pricingData) { double[,] underlyingSpots = ConvertDecimalArray.listDataFeedToDoubleArray(pricingData); double[,] myCorrelationMatrix = StatComputing.correlationMatrix(underlyingSpots); double[] volatility = StatComputing.volatilitiesComputing(underlyingSpots); Pricer pricer = new Pricer(); int nShares = underlyingSpots.GetLength(1); double[] spots = new double[nShares]; for (int i = 0; i < nShares; i++) { spots[i] = underlyingSpots[nShares - 1, i]; } PricingResults pricingResults = pricer.Price((BasketOption)opt, pricingData.Last().Date, 365, spots, volatility, myCorrelationMatrix);; CompletePricingResults completePricingResults = new CompletePricingResults(pricingResults, spots); return(completePricingResults); }
private void updateResults(List <DataFeed> pricingData, int periodIndex, int nRebalancingDays) { CompletePricingResults pricingResult = optionPricer.getPricingResults(pricingData); double[] newDeltas = pricingResult.Deltas; double[] spots = pricingResult.Spots; double optPrice = pricingResult.Price; if (periodIndex == 0) { Array.Copy(newDeltas, deltas, newDeltas.Length); } double riskyAsset = 0; for (int i = 0; i < spots.Length; i++) { riskyAsset += deltas[i] * spots[i]; } if (periodIndex == 0) { results.PortfolioValue = optPrice; } else { results.PortfolioValue = riskyAsset + results.Portfolio.NonRiskyAsset * RiskFreeRateProvider.GetRiskFreeRateAccruedValue(nRebalancingDays / 365.0); } double nonRiskyAsset = results.PortfolioValue - riskyAsset; results.Portfolio = new HedgingPortfolio(riskyAsset, nonRiskyAsset); results.Payoff = optionPricer.Opt.GetPayoff(pricingData.Last().PriceList); results.TrackingError = (results.PortfolioValue - results.Payoff) / optPrice; results.Date = pricingData.Last().Date; deltas = newDeltas; }