• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

Lattice Model Financial Instrument Pricing Using C++

Joined
5/28/23
Messages
10
Points
3
from the book it is using below



double dt = T/N;
double nu = r - 0.5*sig*sig;

// Up and down jumps
double dxu = std::sqrt(sig*sig*dt + (nu*dt)*(nu*dt));
double dxd = -dxu;
// Corresponding probabilities
double pu = 0.5 + 0.5*(nu*dt/dxu);
double pd = 1.0 - pu;
// Precompute constants
double disc = std::exp(-r*dt);
double dpu = disc*pu;
double dpd = disc*pd;
double edxud = std::exp(dxu - dxd);
double edxd = std::exp(dxd);

Whick look different than the common one(which we learn in CFA

Wonder if they are same model, but just different presentation,
or above one is move advance?
 
Last edited:
Looks like code from one of my books?

Which problem are you working on, exactly?
 
Looks like code from one of my books?

Which problem are you working on, exactly?
not exact problem, but just get surprised above "u" are different than what we learned learned in CFA or even CQF

[math]u=e^{\sigma {\sqrt {\Delta }}t}[/math]

[math]d=e^{-\sigma {\sqrt {\Delta }}t}={\frac {1}{u}}.[/math]

[math]p={\frac {e^{(r-q)\Delta t}-d}{u-d}}[/math]

Are this a different model?
 
but just get surprised above "u" are different than what we learned learned in CFA or even CQF
LOL
what do those guys use?

u is up, d is down
 
Last edited:
not exact problem, but just get surprised above "u" are different than what we learned learned in CFA or even CQF

[math]u=e^{\sigma {\sqrt {\Delta }}t}[/math]

[math]d=e^{-\sigma {\sqrt {\Delta }}t}={\frac {1}{u}}.[/math]

[math]p={\frac {e^{(r-q)\Delta t}-d}{u-d}}[/math]

Are this a different model?
There are quite a few models for u, d and p:

CRR, JR, TRG, EQP etc.
 
from the book it is using below



double dt = T/N;
double nu = r - 0.5*sig*sig;

// Up and down jumps
double dxu = std::sqrt(sig*sig*dt + (nu*dt)*(nu*dt));
double dxd = -dxu;
// Corresponding probabilities
double pu = 0.5 + 0.5*(nu*dt/dxu);
double pd = 1.0 - pu;
// Precompute constants
double disc = std::exp(-r*dt);
double dpu = disc*pu;
double dpd = disc*pd;
double edxud = std::exp(dxu - dxd);
double edxd = std::exp(dxd);

Whick look different than the common one(which we learn in CFA

Wonder if they are same model, but just different presentation,
or above one is move advance?
This code is from my 2018 C++ book for barrier options!

On a pedagogical advice to everyone , learn the maths of the binomial method and program it yourselves instead of copying from all kinds of (possibly dodgy) sites.
My two cents..
 
Last edited:
th
This code is from my 2018 C++ book for barrier options!

On a pedagogical advice to everyone , learn the maths of the binomial method and program it yourselves instead of copying from all kinds of (possibly dodgy) sites.
My two cents..
the question is, why Barrier option need to have different formula for u, compared to the generic one shared in wiki?
 
I think I understand now, from wiki

[math]u=e^{\sigma {\sqrt {\Delta }}t}[/math]
[math]d=e^{-\sigma {\sqrt {\Delta }}t}={\frac {1}{u}}[/math]
Above is the original Cox, Ross, & Rubinstein (CRR) method; there are various other techniques for generating the lattice, such as "the equal probabilities" tree, see.[4][5]

So the one mentioned in code book is "other technique", wondering if we have a list of those way how lattice is generating
 
I think I understand now, from wiki

[math]u=e^{\sigma {\sqrt {\Delta }}t}[/math]
[math]d=e^{-\sigma {\sqrt {\Delta }}t}={\frac {1}{u}}[/math]
Above is the original Cox, Ross, & Rubinstein (CRR) method; there are various other techniques for generating the lattice, such as "the equal probabilities" tree, see.[4][5]

So the one mentioned in code book is "other technique", wondering if we have a list of those way how lattice is generating

Is your question "what are the other methods?"

I programmed those methods somewhere I vaguely remember.
 
Do you mean?

C++:
BinomialLatticeStrategy* getStrategy(double sig, double r, double k,
                                        double S, double K, int N)
{
    cout << "\n1. CRR, 2. JR, 3. TRG, 4. EQP, 5. Modified CRR:\n6. Cayley JR Transform: 7 Cayley CRR: ";
    int choice;
    cin >> choice;

    if (choice == 1)
        return new CRRStrategy(sig,r,k);

    if (choice == 2)
        return new JRStrategy(sig,r,k);

    if (choice == 3)
        return new TRGStrategy(sig,r,k);

    if (choice == 4)
        return new EQPStrategy(sig,r,k);

    if (choice == 5)
        return new ModCRRStrategy(sig,r,k, S, K, N);

    if (choice == 6)
        return new PadeJRStrategy(sig,r,k);

    if (choice == 7)
        return new PadeCRRStrategy(sig,r,k);

}
 
Do you mean?

C++:
BinomialLatticeStrategy* getStrategy(double sig, double r, double k,
                                        double S, double K, int N)
{
    cout << "\n1. CRR, 2. JR, 3. TRG, 4. EQP, 5. Modified CRR:\n6. Cayley JR Transform: 7 Cayley CRR: ";
    int choice;
    cin >> choice;

    if (choice == 1)
        return new CRRStrategy(sig,r,k);

    if (choice == 2)
        return new JRStrategy(sig,r,k);

    if (choice == 3)
        return new TRGStrategy(sig,r,k);

    if (choice == 4)
        return new EQPStrategy(sig,r,k);

    if (choice == 5)
        return new ModCRRStrategy(sig,r,k, S, K, N);

    if (choice == 6)
        return new PadeJRStrategy(sig,r,k);

    if (choice == 7)
        return new PadeCRRStrategy(sig,r,k);

}
Many thanks! LEt me study those model
 
I think I understnad better, the u and pu can be different, as long as

pu+pd =1
u*pu +d*pd = r(risk free rate)
 
Back
Top