Esempio n. 1
0
 public JarrowRudd(StochasticProcess1D process, double end, int steps, double strike)
     : base(process, end, steps)
 {
     // drift removed
     up_ = process.stdDeviation(0.0, x0_, dt_);
 }
 public TrinomialTree(StochasticProcess1D process,
                      TimeGrid timeGrid)
     : this(process, timeGrid, false)
 {
 }
Esempio n. 3
0
 public EqualJumpsBinomialTree(StochasticProcess1D process, double end, int steps)
     : base(process, end, steps)
 {
 }
Esempio n. 4
0
        /*! Returns an approximation of the variance defined as
         *  \f$ \sigma(t_0, x_0)^2 \Delta t \f$. */
        public double variance(StochasticProcess1D process, double t0, double x0, double dt)
        {
            double sigma = process.diffusion(t0, x0);

            return(sigma * sigma * dt);
        }
 public ShortRateDynamics(StochasticProcess1D process)
 {
     process_ = process;
 }
Esempio n. 6
0
 public AdditiveEQPBinomialTree(StochasticProcess1D process, double end, int steps, double strike)
     : base(process, end, steps)
 {
     up_ = -0.5 * driftPerStep_ + 0.5 * Math.Sqrt(4.0 * process.variance(0.0, x0_, dt_) - 3.0 * driftPerStep_ * driftPerStep_);
 }
Esempio n. 7
0
 public Trigeorgis factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new Trigeorgis(process, end, steps, strike));
 }
Esempio n. 8
0
 /*! Returns an approximation of the drift defined as
     \f$ \mu(t_0, x_0) \Delta t \f$. */
 public double drift(StochasticProcess1D process, double t0, double x0, double dt)
 {
     return process.drift(t0, x0)*dt;
 }
Esempio n. 9
0
 /*! Returns an approximation of the variance defined as
     \f$ \sigma(t_0, x_0)^2 \Delta t \f$. */
 public double variance(StochasticProcess1D process, double t0, double x0, double dt)
 {
     double sigma = process.diffusion(t0, x0);
     return sigma*sigma*dt;
 }
Esempio n. 10
0
 protected ShortRateDynamics(StochasticProcess1D process)
 {
     process_ = process;
 }
Esempio n. 11
0
 /*! Returns an approximation of the diffusion defined as
     \f$ \sigma(t_0, x_0) \sqrt{\Delta t} \f$. */
 public double diffusion(StochasticProcess1D process, double t0, double x0, double dt)
 {
     return process.diffusion(t0, x0) * Math.Sqrt(dt);
 }
Esempio n. 12
0
 public Joshi4 factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new Joshi4(process, end, steps, strike));
 }
Esempio n. 13
0
 public LeisenReimer factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new LeisenReimer(process, end, steps, strike));
 }
Esempio n. 14
0
 public Tian factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new Tian(process, end, steps, strike));
 }
Esempio n. 15
0
 public JarrowRudd factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new JarrowRudd(process, end, steps, strike));
 }
Esempio n. 16
0
 /*! Returns an approximation of the drift defined as
  *  \f$ \mu(t_0, x_0) \Delta t \f$. */
 public double drift(StochasticProcess1D process, double t0, double x0, double dt)
 {
     return(process.drift(t0, x0) * dt);
 }
Esempio n. 17
0
 public CoxRossRubinstein factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new CoxRossRubinstein(process, end, steps, strike));
 }
Esempio n. 18
0
 /*! Returns an approximation of the diffusion defined as
  *  \f$ \sigma(t_0, x_0) \sqrt{\Delta t} \f$. */
 public double diffusion(StochasticProcess1D process, double t0, double x0, double dt)
 {
     return(process.diffusion(t0, x0) * Math.Sqrt(dt));
 }
Esempio n. 19
0
        public void testSingle(StochasticProcess1D process,
                        string tag, 
                        bool brownianBridge,
                        double expected, 
                        double antithetic)
        {
            ulong seed = 42;
            double length = 10;
            int timeSteps = 12;

            var rsg = (InverseCumulativeRsg<RandomSequenceGenerator<MersenneTwisterUniformRng>
                                                                    ,InverseCumulativeNormal>)
                       new PseudoRandom().make_sequence_generator(timeSteps, seed);

            PathGenerator<IRNG> generator = new PathGenerator<IRNG>(process,
                                                                    length,
                                                                    timeSteps,
                                                                    rsg,
                                                                    brownianBridge);
            int i;
            for (i=0; i<100; i++)
                generator.next();

            Sample<Path> sample = generator.next();
            double calculated = sample.value.back();
            double error = Math.Abs(calculated-expected);
            double tolerance = 2.0e-8;
            if (error > tolerance)
            {
                Assert.Fail("using " + tag + " process "
                            + (brownianBridge ? "with " : "without ")
                            + "brownian bridge:\n"
                            //+ std::setprecision(13)
                            + "    calculated: " + calculated + "\n"
                            + "    expected:   " + expected + "\n"
                            + "    error:      " + error + "\n"
                            + "    tolerance:  " + tolerance);
            }

            sample = generator.antithetic();
            calculated = sample.value.back();
            error = Math.Abs(calculated-antithetic);
            tolerance = 2.0e-7;
            if (error > tolerance)
            {
                Assert.Fail("using " + tag + " process "
                        + (brownianBridge ? "with " : "without ")
                        + "brownian bridge:\n"
                        + "antithetic sample:\n"
                        //+ setprecision(13)
                        + "    calculated: " + calculated + "\n"
                        + "    expected:   " + antithetic + "\n"
                        + "    error:      " + error + "\n"
                        + "    tolerance:  " + tolerance);
            }
        }
Esempio n. 20
0
 public AdditiveEQPBinomialTree factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new AdditiveEQPBinomialTree(process, end, steps, strike));
 }