Serving the Quantitative Finance Community

 
User avatar
NonoSto
Topic Author
Posts: 0
Joined: March 7th, 2009, 9:40 am

Longstaff Schwartz method

March 14th, 2011, 9:24 am

Dear Friend I try to implemente the LSM method with this algorithm:but my price are always too low. By example for a american put with follow parameter : S0 = 36, Strike = 40 , rate = 6%, T = 1 year, discret path = 50, volatility = 20% I found 4 $ but in their article Longstaff and Schwartz found 4,7$. With a volatility 40% the error is bigger with 5$ for me 7,3$ for L & S. But with my tree pricer I have the same result than the L&S article.Could you help me to find the error please?Thanks
 
User avatar
yhilpisch
Posts: 0
Joined: October 18th, 2006, 8:14 am

Longstaff Schwartz method

March 17th, 2011, 8:49 am

Hello,There seems to be an issue with discounting.The line of code almost at the end: discValue = discValue + CashFlow(i, j)*exp(-0.06*j);should include the time spacing parameter dt discValue = discValue + CashFlow(i, j)*exp(-0.06*j*dt);Below a simple implementation of LSM algo in Python.Yves
 
JasmeetGujral
Posts: 2
Joined: June 18th, 2018, 2:55 pm

Re: Longstaff Schwartz method

June 19th, 2018, 1:09 am

@yhilpisch: Need help in debugging my code for LSM. With the current code, my value of American option is lower than European option.
def option_payoff(self, stimulated_price):
        temp_zeros = np.zeros_like(stimulated_price)
        return np.maximum(self.option_flag * (stimulated_price - self.instrument.strike), temp_zeros)

    def LSM_model(self):
        _s_stimulated = self.stimulation_method()
        _intrinsic_val = self.option_payoff(self.stimulation_method())
        _option_value = np.zeros_like(_intrinsic_val)
        _option_value[:, -1] = _intrinsic_val[:, -1]

        for t in range(self.no_of_steps - 1, 0, -1):
            if len(_s_stimulated[_intrinsic_val[:, t] > 0, t]) == 0:
                continue
            else:

                _ITM_check = _intrinsic_val[:, t] > 0
                _x_axis = _s_stimulated[_ITM_check, t]
                _y_axis = _option_value[_ITM_check, t + 1] * self.step_disc_fact
                _option_value[:, t] = _option_value[:, t + 1] * self.step_disc_fact
                _rg = np.polyfit(_x_axis, _y_axis, 5)
                _pv_rg = np.polyval(_rg, _x_axis)

                _option_value[_ITM_check, t] = np.where(_intrinsic_val[_ITM_check, t] > _y_axis,
                                                        _intrinsic_val[_ITM_check, t], _y_axis)

        _option_value[:, 0] = _option_value[:, 1] * self.step_disc_fact
        return np.mean(_option_value[:, 0])

Could you please help me in figuring out what I am missing on my above code.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Longstaff Schwartz method

June 19th, 2018, 7:39 am

Please don't post the same question on multple threads and forums.
This is really "please debug my code". I doubt you will find alpha testers here.

When programming the goal is you program and debug it yourself.
 
User avatar
Gamal
Posts: 1284
Joined: February 26th, 2004, 8:41 am

Re: Longstaff Schwartz method

June 19th, 2018, 8:38 am

This is really "please debug my code". 
Or "please do my work for me."
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Longstaff Schwartz method

June 19th, 2018, 1:16 pm

It's like Teflon, i.e. post on multiple boards and see if it sticks.
 
User avatar
ISayMoo
Posts: 2332
Joined: September 30th, 2015, 8:30 pm

Re: Longstaff Schwartz method

July 8th, 2018, 8:47 pm

After a few years it starts to come off, and gives you cancer?