//We test that the display of the cost of a shape is working well. //It is the answer to the question 4. public void TestTheDisplayCostOfShapeMethodUsingPriceClass() { IPricer pricer = new Pricer(); Shape square = new Square("Square1", 12, pricer); Assert.AreEqual("Square - Square1 - 12 cm² - Estimation coût : 24€", square.displayCostOfShape()); }
static void Main(string[] args) { string fileName = Path.Combine(TEST_FILE_PATH_LOCAL, "pricer.in");// // @"C:\Users\Tanveer\Source\Repos\LOB\" + "pricer.in"; #if CONSOLE StringReader rdr = new StringReader(Test.SAMPLE_INPUT); #else TextReader rdr = new StreamReader(fileName); #endif int targetSize = int.Parse(args[0]); string outFilePath = Path.Combine(TEST_FILE_PATH_LOCAL, targetSize.ToString() + "-LL.out"); var sbOp = new StringBuilder(); #if CONSOLE TextWriter writer = Console.Out; #else TextWriter writer = new StringWriter(sbOp); #endif var pricer = new Pricer(targetSize); //Task.Factory.StartNew(() => pricer.doWork(rdr, Console.Out)); pricer.doWork(rdr, writer); File.WriteAllText(outFilePath, sbOp.ToString(), Encoding.GetEncoding(28591)); //Console.WriteLine(sbOp.ToString()); }
public BasketPricingModel() { basketPricer = new Pricer(); oName = "Basket"; oObservation = 30; tauxSR = PricingLibrary.Utilities.MarketDataFeed.RiskFreeRateProvider.GetRiskFreeRate(); }
internal override DoubleArray computedBucketedCs01(ResolvedCdsTrade trade, IList <ResolvedCdsTrade> bucketCds, CreditRatesProvider ratesProvider, ReferenceData refData) { checkCdsBucket(trade, bucketCds); ResolvedCds product = trade.Product; Currency currency = product.Currency; StandardId legalEntityId = product.LegalEntityId; LocalDate valuationDate = ratesProvider.ValuationDate; int nBucket = bucketCds.Count; DoubleArray impSp = impliedSpread(bucketCds, ratesProvider, refData); NodalCurve creditCurveBase = Calibrator.calibrate(bucketCds, impSp, DoubleArray.filled(nBucket), CurveName.of("baseImpliedCreditCurve"), valuationDate, ratesProvider.discountFactors(currency), ratesProvider.recoveryRates(legalEntityId), refData); IsdaCreditDiscountFactors df = IsdaCreditDiscountFactors.of(currency, valuationDate, creditCurveBase); CreditRatesProvider ratesProviderBase = ratesProvider.toImmutableCreditRatesProvider().toBuilder().creditCurves(ImmutableMap.of(Pair.of(legalEntityId, currency), LegalEntitySurvivalProbabilities.of(legalEntityId, df))).build(); double[][] res = new double[nBucket][]; PointSensitivities pointPv = Pricer.presentValueOnSettleSensitivity(trade, ratesProviderBase, refData); DoubleArray vLambda = ratesProviderBase.singleCreditCurveParameterSensitivity(pointPv, legalEntityId, currency).Sensitivity; for (int i = 0; i < nBucket; i++) { PointSensitivities pointSp = Pricer.parSpreadSensitivity(bucketCds[i], ratesProviderBase, refData); res[i] = ratesProviderBase.singleCreditCurveParameterSensitivity(pointSp, legalEntityId, currency).Sensitivity.toArray(); } DoubleMatrix jacT = MATRIX_ALGEBRA.getTranspose(DoubleMatrix.ofUnsafe(res)); LUDecompositionResult luRes = DECOMPOSITION.apply(jacT); DoubleArray vS = luRes.solve(vLambda); return(vS); }
//We test that the price method of the Pricer Class we have to implement //is working well. It is the answer to the question 4. public void TestThePriceMethodOfPricerClass() { IPricer pricer = new Pricer(); Shape square = new Square("Square1", 12); Assert.AreEqual(24, pricer.Price(square.Area)); }
public void TestGetPrice() { var strikePrice = 100; var underlyingPrice = 90; var daysUntilExpiration = 230 / 365.0; var volatility = 0.5; var interestRate = 0.1; var d1 = 0.09176057; var d2 = -0.30514527; var cdfComputer = Substitute.For <INormalCdfComputer>(); cdfComputer.Compute(Arg.Is <double>(c => Math.Abs(Math.Round(c, 8) - d1) < double.Epsilon)).Returns(0.5365558638); cdfComputer.Compute(Arg.Is <double>(c => Math.Abs(Math.Round(c, 8) + d1) < double.Epsilon)).Returns(1 - 0.5365558638); cdfComputer.Compute(Arg.Is <double>(c => Math.Abs(Math.Round(c, 8) - d2) < double.Epsilon)).Returns(0.3801277569); cdfComputer.Compute(Arg.Is <double>(c => Math.Abs(Math.Round(c, 8) + d2) < double.Epsilon)).Returns(1 - 0.3801277569); var callParameter = new PricerParameter(OptionType.Call, underlyingPrice, strikePrice, daysUntilExpiration, interestRate, volatility); var putParameter = new PricerParameter(OptionType.Put, underlyingPrice, strikePrice, daysUntilExpiration, interestRate, volatility); var pricer = new Pricer(cdfComputer); var callPrice = Math.Round(pricer.GetPrice(callParameter), 4); var putPrice = Math.Round(pricer.GetPrice(putParameter), 4); Assert.That(callPrice, Is.EqualTo(12.5987)); Assert.That(putPrice, Is.EqualTo(16.4917)); }
//------------------------------------------------------------------------- public override CurrencyAmount parallelCs01(ResolvedCdsTrade trade, IList <ResolvedCdsTrade> bucketCds, CreditRatesProvider ratesProvider, ReferenceData refData) { checkCdsBucket(trade, bucketCds); ResolvedCds product = trade.Product; Currency currency = product.Currency; StandardId legalEntityId = product.LegalEntityId; LocalDate valuationDate = ratesProvider.ValuationDate; ImmutableCreditRatesProvider immutableRatesProvider = ratesProvider.toImmutableCreditRatesProvider(); int nBucket = bucketCds.Count; DoubleArray impSp = impliedSpread(bucketCds, ratesProvider, refData); NodalCurve creditCurveBase = Calibrator.calibrate(bucketCds, impSp, DoubleArray.filled(nBucket), CurveName.of("baseImpliedCreditCurve"), valuationDate, ratesProvider.discountFactors(currency), ratesProvider.recoveryRates(legalEntityId), refData); Pair <StandardId, Currency> lePair = Pair.of(legalEntityId, currency); IsdaCreditDiscountFactors df = IsdaCreditDiscountFactors.of(currency, valuationDate, creditCurveBase); CreditRatesProvider ratesProviderBase = immutableRatesProvider.toBuilder().creditCurves(ImmutableMap.of(lePair, LegalEntitySurvivalProbabilities.of(legalEntityId, df))).build(); CurrencyAmount pvBase = Pricer.presentValueOnSettle(trade, ratesProviderBase, PriceType.DIRTY, refData); DoubleArray bumpedSp = DoubleArray.of(nBucket, i => impSp.get(i) + bumpAmount); NodalCurve creditCurveBump = Calibrator.calibrate(bucketCds, bumpedSp, DoubleArray.filled(nBucket), CurveName.of("bumpedImpliedCreditCurve"), valuationDate, ratesProvider.discountFactors(currency), ratesProvider.recoveryRates(legalEntityId), refData); IsdaCreditDiscountFactors dfBump = IsdaCreditDiscountFactors.of(currency, valuationDate, creditCurveBump); CreditRatesProvider ratesProviderBump = immutableRatesProvider.toBuilder().creditCurves(ImmutableMap.of(lePair, LegalEntitySurvivalProbabilities.of(legalEntityId, dfBump))).build(); CurrencyAmount pvBumped = Pricer.presentValueOnSettle(trade, ratesProviderBump, PriceType.DIRTY, refData); return(CurrencyAmount.of(currency, (pvBumped.Amount - pvBase.Amount) / bumpAmount)); }
public static double UpdatePortfolio(DateTime maturity, double risklessRate, DateTime date, SimulatedDataFeedProvider data, VanillaCall call, int nbDaysPerYear, double volatility) { List <DataFeed> spotList = data.GetDataFeed(call, date); // decimal spot = spotList[0].PriceList[call.UnderlyingShare.Id]; PricingResults price; price = Pricer.PriceCall(call, date, nbDaysPerYear, (double)spot, volatility); // double pricePortfolio = price.Price; double delta = price.Deltas[0]; double riskyPosition = delta; //Dictionary<string, decimal> price = datafeed.PriceList.TryGetValue(call.Name,out 0); double riskFreePosition = pricePortfolio - delta * (double)spot; while (date < maturity) { date.AddDays(1); spotList = data.GetDataFeed(call, date); // spot = spotList[0].PriceList[call.UnderlyingShare.Id]; pricePortfolio = riskyPosition * (double)spot + riskFreePosition * Math.Exp(risklessRate / 365); price = Pricer.PriceCall(call, date, nbDaysPerYear, (double)spot, volatility); // delta = price.Deltas[0]; riskyPosition = delta; riskFreePosition = pricePortfolio - delta * (double)spot; } return(riskyPosition * (double)spot + riskFreePosition * Math.Exp(risklessRate / 365)); }
public void Actual(DataTestCase testCase) { Data.InitMarketData(testCase.Vol, testCase.Rate, testCase.EvalDate); var pricingCfg = new PricingConfiguration(testCase.GreekTypes); var pricer = new Pricer(); PricingResults expectedResults = null; var actualResults = pricer.Results(testCase.Option, pricingCfg); var error = string.Empty; try { using (StreamReader file = File.OpenText(@"C:\Users\AHMED\source\repos\ConsoleApp1\ResultPricing.text")) { JsonSerializer serializer = new JsonSerializer(); expectedResults = (PricingResults)serializer.Deserialize(file, typeof(PricingResults)); } } catch (Exception e) { Assert.Fail(error = string.Format("Not Deserialize result: {0}", e.Message)); } if (actualResults.CompareResult(expectedResults)) { Assert.Pass("No regression detected"); } else { // save ecart Assert.Fail("regression detected"); } }
protected void OnOracleGetPriceCommand(string[] args) { var apiKey = _cli.CryptoCompareAPIKey; var pricerCGEnabled = _cli.Settings.Oracle.PricerCoinGeckoEnabled; var pricerSupportedTokens = _cli.Settings.Oracle.PricerSupportedTokens.ToArray(); Console.WriteLine($"Supported tokens:"); Console.WriteLine($"---------------------------"); foreach (var token in pricerSupportedTokens) { Console.WriteLine($"{token.ticker}: {token.cryptocompareId}: {token.coingeckoId}"); } Console.WriteLine($"---------------------------"); if (pricerCGEnabled) { var cgprice = CoinGeckoUtils.GetCoinRate(args[0], DomainSettings.FiatTokenSymbol, pricerSupportedTokens, Spook.Logger); Console.WriteLine($"Oracle Coingecko Price for token {args[0]} is: {cgprice}"); } var price = CryptoCompareUtils.GetCoinRate(args[0], DomainSettings.FiatTokenSymbol, apiKey, pricerSupportedTokens, Spook.Logger); Console.WriteLine($"Oracle CryptoCompare Price for token {args[0]} is: {price}"); var gprice = Pricer.GetCoinRate(args[0], DomainSettings.FiatTokenSymbol, apiKey, pricerCGEnabled, pricerSupportedTokens, Spook.Logger); Console.WriteLine($"Oracle Global Price for token {args[0]} is: {gprice}"); }
public PricingResults PriceResults(IOption option, Dictionary <string, decimal> priceMarket, DateTime dateDebut, IDataFeedProvider dataFeedProvider) { Pricer pricer = new Pricer(); int length = priceMarket.Count; double[] spot = new double[length]; for (int i = 0; i < spot.Length; i++) { spot[i] = (double)priceMarket.ElementAt(i).Value; } if (option is VanillaCall) { VanillaCall optionVanilla = (VanillaCall)option; PricingResults priceDelta = pricer.PriceCall(optionVanilla, dateDebut, dataFeedProvider.NumberOfDaysPerYear, spot[0], volatilite); return(priceDelta); } else { BasketOption optionBasket = (BasketOption)option; double[] volatilities = new double[optionBasket.Weights.Length]; for (int i = 0; i < optionBasket.Weights.Length; i++) { volatilities[i] = volatilite; } PricingResults priceDelta = pricer.PriceBasket(optionBasket, dateDebut, dataFeedProvider.NumberOfDaysPerYear, spot, volatilities, matrixCorrelation); return(priceDelta); } }
public void UpdatePortfolio(DateTime lastUpdateDate, DateTime newUpdateDate) { int LastUpdateDateIndex = AppData.DaysFromStart(lastUpdateDate); int NewUpdateDateIndex = AppData.DaysFromStart(newUpdateDate); Price = Pricer.price(NewUpdateDateIndex, AppData.MarketData); double riskyAsset; int i, t; for (t = LastUpdateDateIndex + 1; t <= NewUpdateDateIndex; t++) { PortfolioValue = 0; riskyAsset = 0; for (i = 0; i < AppData.NbShares; i++) { PortfolioValue += Deltas[i] * AppData.MarketData[t, i]; } PortfolioValue += NonRiskyAsset * Math.Exp(AppData.R / 365.0); // car deltaTime = 1/365.0 Deltas = Pricer.deltas(t, AppData.MarketData); for (i = 0; i < AppData.NbShares; i++) { riskyAsset += Deltas[i] * AppData.MarketData[t, i]; // nouveau delta calculés } NonRiskyAsset = PortfolioValue - riskyAsset; } }
internal override DoubleArray computedBucketedCs01(ResolvedCdsTrade trade, IList <ResolvedCdsTrade> bucketCds, CreditRatesProvider ratesProvider, ReferenceData refData) { checkCdsBucket(trade, bucketCds); ResolvedCds product = trade.Product; Currency currency = product.Currency; StandardId legalEntityId = product.LegalEntityId; LocalDate valuationDate = ratesProvider.ValuationDate; ImmutableCreditRatesProvider immutableRatesProvider = ratesProvider.toImmutableCreditRatesProvider(); int nBucket = bucketCds.Count; double[] res = new double[nBucket]; DoubleArray impSp = impliedSpread(bucketCds, ratesProvider, refData); NodalCurve creditCurveBase = Calibrator.calibrate(bucketCds, impSp, DoubleArray.filled(nBucket), CurveName.of("baseImpliedCreditCurve"), valuationDate, ratesProvider.discountFactors(currency), ratesProvider.recoveryRates(legalEntityId), refData); Pair <StandardId, Currency> lePair = Pair.of(legalEntityId, currency); IsdaCreditDiscountFactors df = IsdaCreditDiscountFactors.of(currency, valuationDate, creditCurveBase); CreditRatesProvider ratesProviderBase = immutableRatesProvider.toBuilder().creditCurves(ImmutableMap.of(lePair, LegalEntitySurvivalProbabilities.of(legalEntityId, df))).build(); double pvBase = Pricer.presentValueOnSettle(trade, ratesProviderBase, PriceType.DIRTY, refData).Amount; for (int i = 0; i < nBucket; ++i) { double[] bumpedSp = impSp.toArray(); bumpedSp[i] += bumpAmount; NodalCurve creditCurveBump = Calibrator.calibrate(bucketCds, DoubleArray.ofUnsafe(bumpedSp), DoubleArray.filled(nBucket), CurveName.of("bumpedImpliedCreditCurve"), valuationDate, ratesProvider.discountFactors(currency), ratesProvider.recoveryRates(legalEntityId), refData); IsdaCreditDiscountFactors dfBump = IsdaCreditDiscountFactors.of(currency, valuationDate, creditCurveBump); CreditRatesProvider ratesProviderBump = immutableRatesProvider.toBuilder().creditCurves(ImmutableMap.of(lePair, LegalEntitySurvivalProbabilities.of(legalEntityId, dfBump))).build(); double pvBumped = Pricer.presentValueOnSettle(trade, ratesProviderBump, PriceType.DIRTY, refData).Amount; res[i] = (pvBumped - pvBase) / bumpAmount; } return(DoubleArray.ofUnsafe(res)); }
static void Main(string[] args) { DateTime expirationDate = DateTime.Parse("01/05/2019"); DateTime riskFactorDate = DateTime.Parse("01/09/2019"); DateTime paramDate = DateTime.Parse("01/04/2019"); var option = new OptionInstrument(60, expirationDate, OptionType.Put, Way.Sell, Underlying.Petrol, riskFactorDate); Data.InitMarketData(0.25, 0.05, paramDate); var pricingcfg = new PricingConfiguration( new List <GreekType> { GreekType.Delta, GreekType.Gamma, GreekType.Vega, GreekType.Rho, GreekType.Tetha }); var pricer = new Pricer(); var results = pricer.Results(option, pricingcfg); Console.WriteLine("Le prix de l'option :" + results.Mtm); foreach (var result in results.Results) { Console.WriteLine("La valeur de " + result.Key.ToString() + " : " + result.Value); } /*// prcing europeene option * var maturity = DateTime.Parse("01/05/2019"); * var paramDate = DateTime.Parse("01/04/2019"); * var riskFctorDate = DateTime.Parse("01/09/2019"); * var diif = (paramDate-maturity).TotalDays; * var option = new OptionInstrument(60, maturity); * var interpolator = new InterpolatorFuturePrice("CL", riskFctorDate); * var riskFator = interpolator.InterpolationBackStepProcess(); * var optionData = new OptionMarketData(riskFator, paramDate, 0.05, 0.25); * * var pricer = new OptionPricer(option, optionData,"call"); * * * var listGreeks = new List<string>() * { * "Delta", * "Vega", * "Theta", * "Rho", * "Gamma" * }; * * PrintResult print = new PrintResult(pricer,true,true,listGreeks); * print.Print(); */ // InitMarketData // Construction of Product + PricingConfiguration // Call the method Price }
public override double CalculerPrix(int jour, AbstractData donnees, double[] spot, double[,] corr, double[] vol) { Pricer pricer = new Pricer(); DateTime dateAvancee = donnees.listeDate[jour]; double prix = pricer.PriceCall((VanillaCall)this.option, dateAvancee, 365, spot[0], vol[0]).Price; return(prix); }
public override double[] CalculerDeltas(int jour, AbstractData donnees, double[] vol, double[,] corr, double[] spot) { Pricer pricer = new Pricer(); DateTime dateAvancee = donnees.listeDate[jour]; double[] deltas = pricer.PriceCall((VanillaCall)this.option, dateAvancee, 365, spot[0], vol[0]).Deltas; return(deltas); }
/** * Constrctor for a VanillaPricingModel. * * */ public VanillaCallPricingModel() { vanillaPricer = new Pricer(); oName = "Vanilla"; tauxSR = PricingLibrary.Utilities.MarketDataFeed.RiskFreeRateProvider.GetRiskFreeRate(); oSpot = new double[1]; oObservation = 30; }
public override double[] CalculerDeltas(int jour, AbstractData donnees, double[] vol, double[,] corr, double[] spot) { Pricer pricer = new Pricer(); DateTime dateAvancee = donnees.listeDate[jour]; double[] deltas = pricer.PriceBasket((BasketOption)this.option, dateAvancee, 365, spot, vol, corr).Deltas; return(deltas); }
public override double CalculerPrix(int jour, AbstractData donnees, double[] spot, double[,] corr, double[] vol) { Pricer pricer = new Pricer(); DateTime dateAvancee = donnees.listeDate[jour]; double prix = pricer.PriceBasket((BasketOption)this.option, dateAvancee, 365, spot, vol, corr).Price; return(prix); }
public IActionResult PostOrder([FromForm] IFormCollection form) { Pricer register = new Pricer(); register.TotalPrice(form); return(RedirectToAction("Details", "OrderPizzas")); }
public void Pricer_Throws_WhenNoStrategy() { var pricer = new Pricer(); var basket = CreateBasket('A', 'B', 'C'); Should.Throw <InvalidOperationException>(() => { pricer.GetPrice(basket); }); }
public void Pricer_UsesSinglePricingStrategy() { var pricer = new Pricer(new DummyOffer()); var basket = CreateBasket('A', 'B', 'C', 'D'); var price = pricer.GetPrice(basket); price.ShouldBe(6M); }
public void Given_Product_Should_Compute_Price_V2(Product product, decimal expectedPrice) { // arrange var pricer = new Pricer(); // act var price = pricer.Compute(product); // assert price.Should().BeApproximately(expectedPrice, precision); }
public Balancement(IDataFeedProvider dataFeedProvider, IOption option, DateTime dateTmpDebut, int plageEstimation, int periodeRebalancement) { var dateDebut = new DateTime(dateTmpDebut.Year, dateTmpDebut.Month, dateTmpDebut.Day); var priceList = dataFeedProvider.GetDataFeed(option, dateDebut); payoff = payOffaMaturite(option, priceList); pricer = new Pricer(); hedge = new List <decimal>(); priceOption = new List <double>(); dates = new List <DateTime>(); Dictionary <string, double> compo = new Dictionary <string, double> { }; volatilite = Estimateur.Volatilite(priceList, plageEstimation, dateDebut.AddDays(plageEstimation), option, dataFeedProvider); matrixCorrelation = Estimateur.getCorrMatrix(priceList, plageEstimation, dateDebut.AddDays(plageEstimation)); Estimateur.dispMatrix(matrixCorrelation); PricingResults priceDelta = PriceResults(option, priceList[0].PriceList, dateDebut, dataFeedProvider); int i = 0; foreach (string id in option.UnderlyingShareIds) { compo[id] = priceDelta.Deltas[i]; i += 1; } DateTime oldBalancement = dateDebut; portfolio = new Portfolio(Convert.ToDecimal(priceDelta.Price), compo, priceList[0].PriceList); priceOption.Add(priceDelta.Price); hedge.Add(portfolio.portfolioValue); dates.Add(priceList[0].Date); foreach (DataFeed priceAsset_t in priceList.Skip(1)) { if (DayCount.CountBusinessDays(oldBalancement, priceAsset_t.Date) >= periodeRebalancement || priceAsset_t == priceList.Last()) { priceDelta = PriceResults(option, priceAsset_t.PriceList, dateDebut, dataFeedProvider); priceOption.Add(priceDelta.Price); portfolio.UpdatePortfolioValue(priceAsset_t, dataFeedProvider.NumberOfDaysPerYear, oldBalancement); i = 0; foreach (string id in option.UnderlyingShareIds) { compo[id] = priceDelta.Deltas[i]; i += 1; } hedge.Add(portfolio.portfolioValue); dates.Add(priceAsset_t.Date); portfolio.UpdateLiquidity(priceAsset_t); portfolio.UpdateCompo(compo); oldBalancement = priceAsset_t.Date; } } }
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 void MultiBuyOffer_PicksSpecifiedNumberOfSKU() { var pricer = new Pricer( new MultiBuyOffer(new SKU('A'), 3, 10M), new SingleItemOffer(new SKU('A'), 4M) ); var price = pricer.GetPrice(CreateBasket('A', 'A', 'A', 'A')); price.ShouldBe(14M); }
public void Given_Basket_Should_Compute_Price(Basket basket, decimal expectedPrice) { // arrange var pricer = new Pricer(); // act var price = pricer.Compute(basket); // assert price.Should().BeApproximately(expectedPrice, precision); }
public TrainingForm() { InitializeComponent(); _instrumentRepository = new MyInstrumentRepository(); _instrumentRepository.Init(20); _pricer = new Pricer(_instrumentRepository, 1); _instruments = new ObservableCollection <InstrumentViewModel>( _instrumentRepository.GetInstruments().Select(instrument => new InstrumentViewModel(instrument))); }
public void getCallTest1() { double stockPrice = 50; double strikePrice = 55; double timeToMaturity = 1; double standardDeviation = 0.2; double risk = 0.09; Pricer p = new Pricer(stockPrice, strikePrice, timeToMaturity, standardDeviation, risk); Assert.AreEqual(3.8617, p.getCall()); }
public void getPutTest2() { double stockPrice = 64; double strikePrice = 60; double timeToMaturity = 180 / 365; double standardDeviation = 0.27; double risk = 0.045; Pricer p = new Pricer(stockPrice, strikePrice, timeToMaturity, standardDeviation, risk); Assert.AreEqual(2.4493, p.getPut()); }
private void Button_Click(object sender, RoutedEventArgs e) { GetData(out vol, out strikeValue, out interestRate, out valueDate, out maturityDate, out riskfacorDate); way = (Way)System.Enum.Parse(typeof(Way), Way.SelectedItem.ToString()); optionType = (OptionType)System.Enum.Parse(typeof(OptionType), TypeOption.SelectedItem.ToString()); sousJacent = (Underlying)System.Enum.Parse(typeof(Underlying), sousjacent.SelectedItem.ToString()); var x = MyGreeks.SelectedItems; var z = MyGreeks.SelectedItem; listGreeks = MyGreeks.SelectedItems.Cast <GreekType>().ToList(); Data.InitMarketData(vol, interestRate, valueDate); var option = new OptionInstrument(strikeValue, maturityDate, optionType, way, sousJacent, riskfacorDate); var pricingcfg = new PricingConfiguration(listGreeks); var pricer = new Pricer(); Result.Text = pricer.Results(option, pricingcfg).Mtm.ToString(); var resultGreek = pricer.Results(option, pricingcfg).Results; if (resultGreek.Count != 0) { foreach (var result in resultGreek) { switch (result.Key) { case GreekType.Delta: ValueDelta.Text = result.Value.ToString(""); break; case GreekType.Vega: ValueVega.Text = result.Value.ToString(); break; case GreekType.Gamma: ValueGamma.Text = result.Value.ToString(); break; case GreekType.Rho: ValueRho.Text = result.Value.ToString(); break; case GreekType.Tetha: ValueTetha.Text = result.Value.ToString(); break; } } } }
private async void btnGo_Click(object sender, EventArgs e) { string expectedOp = Test.EXPECTED_OUTPUT_FOR_SAMPLE_INPUT; int targetSize = (int)numericUpDown1.Value; //if (_rdr == null) _rdr = new StringReader(Test.SAMPLE_INPUT); var outputString = new StringBuilder(); TextWriter writer = new StringWriter(outputString); var pricer = new Pricer(targetSize); #if DEBUG pricer.DobChanged += pricer_DobChanged; pricer.NewLineProcessed += (s, arg) => this.Invoke(new Action(() => this.textBox1.Text = arg + Environment.NewLine + this.textBox1.Text)); #endif await Task.Factory.StartNew(() => pricer.doWork(_rdr, Console.Out)); //pricer.doWork(_rdr, Console.Out); this.textBox1.Text = outputString.ToString() + Environment.NewLine + " ==================" + Environment.NewLine + textBox1.Text; ; }