American Option Pricing via Longstaff and Schwartz (2001)
2015-05-07 09:21
609 查看
import numpy as np import matplotlib.pyplot as plt import numpy.random as npr def gen_sn(M, I, anti_paths=True, mo_match=True): if anti_paths is True: sn = npr.standard_normal((M+1, I/2)) sn = np.concatenate((sn,-sn), axis=1) else: sn = npr.standard_normal((M+1, I)) if mo_match is True: sn = (sn-sn.mean())/sn.std() return sn def gbm_mcs_amer(K, option='C'): # set model paramters S0 = 100 # initial stock level T = 1.0 # time to maturity r = 0.05 # risk free rate vol = 0.20 # volatility M = 1000 # time stpes dt = T/M df = np.exp(-r*dt) # simulation of stock levels S = np.zeros((M+1, I)) S[0] = S0 rn = gen_sn(M, I) for t in range(1, M+1): S[t] = S[t-1]*np.exp((r-0.5*vol**2)*dt+vol*np.sqrt(dt)*rn[t]) if option == 'call': h = np.maximum(S-K, 0) else: h = np.maximum(K-S, 0) # LSM method V = np.copy(h) for t in range(M-1, 0, -1): # calculate holding value: present value of next period payoff # regression to get expected holding value reg = np.polyfit(S[t], V[t+1]*df, 3) C = np.polyval(reg, S[t]) # compare with exercise value V[t] = np.where(C>h[t], V[t+1]*df, h[t]) # option value at time 0 C0 = df*np.sum(V[1])/I return C0 print gbm_mcs_amer(100)
相关文章推荐
- American Option Pricing via Longstaff and Schwartz (2001)
- Vanilla Option Pricing via C++
- Vanilla Option Pricing via C++
- 期权:Black-Scholes put and call option pricing
- getop() and getopt_long()
- AFNetworking 关于JSON text did not start with array or object and option to allow fragments not set
- long long data type in GCC and what's the meaning of 1LL
- (原創) 如何解決『Error: More than one programming cable found in available hardware list --use--list option to display available hardware list and specify correct cableprogramming』錯誤訊息? (SOC) (Nios II) (μClinux) (DE2) (DE2-70)
- Both differential and cumulative backup work with compressed option in 11G.
- Without `from` option PostCSS could generate wrong source map and will not find Browserslist config.
- 【论文阅读笔记】CVPR2015-Long-term Recurrent Convolutional Networks for Visual Recognition and Description
- "Argument list too long": Beyond Arguments and Limitations
- Web Mining via Phantom.js and SharpKit at DevTalk.net
- CLR Via C# 3rd 阅读摘要 -- Chapter 23 – Assembly Loading and Reflection
- service structure flowchart [mobile to server via HTTP RESTful API and TCP/IP in a map]
- How do the Match Approval Level Option and Invoice Match Option work?
- [TypeScript] Restrict null and undefined via Non-Nullable-Types in TypeScript
- You called this URL via POST, but the URL doesn't end in a slash and you hav。。。
- Oracle: Benefits and consequences of the NOLOGGING option
- Please make sure the -vm option in eclipse.ini is pointing to a JDK and verify that Installed JRE’s