Exemplo 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)
 {
 }
Exemplo n.º 3
0
 public EqualJumpsBinomialTree(StochasticProcess1D process, double end, int steps)
     : base(process, end, steps)
 {
 }
Exemplo 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;
 }
Exemplo 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_);
 }
Exemplo n.º 7
0
 public Trigeorgis factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new Trigeorgis(process, end, steps, strike));
 }
Exemplo 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;
 }
Exemplo 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;
 }
Exemplo n.º 10
0
 protected ShortRateDynamics(StochasticProcess1D process)
 {
     process_ = process;
 }
Exemplo 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);
 }
Exemplo n.º 12
0
 public Joshi4 factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new Joshi4(process, end, steps, strike));
 }
Exemplo n.º 13
0
 public LeisenReimer factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new LeisenReimer(process, end, steps, strike));
 }
Exemplo n.º 14
0
 public Tian factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new Tian(process, end, steps, strike));
 }
Exemplo n.º 15
0
 public JarrowRudd factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new JarrowRudd(process, end, steps, strike));
 }
Exemplo 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);
 }
Exemplo n.º 17
0
 public CoxRossRubinstein factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new CoxRossRubinstein(process, end, steps, strike));
 }
Exemplo 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));
 }
Exemplo 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);
            }
        }
Exemplo n.º 20
0
 public AdditiveEQPBinomialTree factory(StochasticProcess1D process, double end, int steps, double strike)
 {
     return(new AdditiveEQPBinomialTree(process, end, steps, strike));
 }