Пример #1
0
        private double SolveCouponRate(double upfrontMargin = 0.0)
        {
            // Display
            Console.WriteLine("Solving for the coupon rate on {0}", pricingDate());
            double targetPrice = 1.0 - upfrontMargin;


            // Price with high level of coupon (upper bound)
            double     highCoupon = 0.10;
            myAutocall AC_high    = GetAutocall(1.0, highCoupon);

            AC_high.setPricingEngine(Engine(pricingDate(), currentMarketData()));
            double px_high = AC_high.NPV();

            Console.WriteLine("Found a high price of {0}", px_high.ToString("P", System.Globalization.CultureInfo.InvariantCulture));


            // price with low level of coupon (lower bound)
            double     lowCoupon = 0.00;
            myAutocall AC_low    = GetAutocall(1.0, lowCoupon);

            AC_low.setPricingEngine(Engine(pricingDate(), currentMarketData()));
            double px_low = AC_low.NPV();

            Console.WriteLine("Found a low price of {0}", px_low.ToString("P", System.Globalization.CultureInfo.InvariantCulture));

            // Coupon rate linear estimation
            double estimation = lowCoupon + (highCoupon - lowCoupon) / (px_high - px_low) * (targetPrice - px_low);

            Console.WriteLine("Coupon rate estimated at {0}", estimation.ToString("P", System.Globalization.CultureInfo.InvariantCulture));

            // Return
            return(estimation);
        }
Пример #2
0
        protected void Invest(DateTime date, double notional, MarkitSurface marketData)
        {
            // Get a new product for investment on date
            myAutocall newProduct = _instrumentHelper.Instrument(date, notional, marketData);

            Console.WriteLine("New autocall product constructed.");

            // Withdrawing from bank account to fund investment
            _bankAccount.Transaction(date, -1 * notional);

            // Add new investment to active positions
            Guid id = Guid.NewGuid();

            _activePositions[id] = new AutocallPosition(newProduct, _instrumentHelper, id);
            Console.WriteLine("New autocall product added to the active positions under GUID: {0}", id);
        }
Пример #3
0
        protected void SetEngine(myAutocall autocallInstrument, DateTime d, MarkitSurface marketData)
        {
            // Get stochastic process
            var stochasticProcess = GetStochasticProcess(d, marketData);

            // Set properties
            IPricingEngine monteCarloEngine = new MakeMCEuropeanAutocallEngine <PseudoRandom>(stochasticProcess)
                                              .withSteps(timeSteps())
                                              .withAntitheticVariate(antithetic())
                                              .withBrownianBridge(brownianBridge())
                                              .withSamples(samples())
                                              .withSeed(seed())
                                              .value();

            // Apply engine to instrument
            autocallInstrument.setPricingEngine(monteCarloEngine);
        }