a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 學院 > 開發設計 > 正文

Homework #1 for MAFS 5220

2019-11-14 10:23:12
字體:
來源:轉載
供稿:網友
"""Created on Sun Nov 6 16:26:56 2016@author: Stan WangAssignment_1 Delta hedging of an option"""import scipy as spimport mathimport numpy as npimport scipy.stats as ssdef d1(S0, K, r, sigma, T): return (np.log(S0/K) + (r + sigma**2 / 2) * T)/(sigma * np.sqrt(T))def d2(S0, K, r, sigma, T): return (np.log(S0/K) + (r - sigma**2 / 2) * T)/(sigma * np.sqrt(T))# the Black-Shoes option PRicedef BS_Call(S0, K, r, sigma, T): return S0 * ss.norm.cdf(d1(S0, K, r, sigma, T)) - K * np.exp(-r * T) * ss.norm.cdf(d2(S0, K, r, sigma, T))def MC_deltaHedging_Call(S # stock price ,X # strike price ,T # maturity ,sigma # volatility ,expectedReturn # the stock's expected Return ,r # riskless return rate ,numMC # number of Monte Carlo ,numsim # number of days to the maturity ): dt = T/float(numsim) drift=(r-0.5*sigma*sigma)*dt sigmasqrtdt = sigma * math.sqrt(dt) portfolio = sp.zeros([numMC],dtype=float) interest = np.exp(r*dt) # Assume that we adjust our portfolio at the beginning of the business day; for j in range(0,numMC): # At the first day #print("In the first day: ") stockPrice = S callValue01 = BS_Call(stockPrice,X,r,sigma,T) # according to BS, delta=N(d1) delta01 = ss.norm.cdf(d1(stockPrice,X,r,sigma,T)) # we long one call option, and short delta stock to hedge it. # and we put the extra money(positive or negative) # into the money account moneyAccount = delta01 * stockPrice - callValue01 print("the stock price is {}".format(stockPrice)) print("to hedge one call option, we sell {} shares of stock".format(delta01)) # From the second day to the last day for i in range(1,numsim): print("in the {} day: ".format(i+1)) # assume that the stock price is GBM e = sp.random.normal(0,1) stockPrice *= np.exp(drift + sigmasqrtdt * e) print("the stock price is {}".format(stockPrice) ) # every day the money in the money account will earn or pay # interest at the rate of r; moneyAccount *= interest # the call value and corresponding delta; callValue02 = BS_Call(stockPrice,X,r,sigma,T-i*dt) delta02 = ss.norm.cdf(d1(stockPrice,X,r,sigma,T-i*dt)) # P&L of this call option; PnL_call = callValue02 - callValue01 print("the P&L of the option is {}".format(PnL_call)) print("the new delta is {}".format(delta01)) # due to new delta, we need to buy or sell stocks at the value of # delta01 - delta02 which means buying if positive, or selling if # negative; print("the amount of stock we changed is {}".format(delta01-delta02)) # adjust the value of money account; moneyAccount +=(delta02-delta01)*stockPrice delta01 = delta02 callValue01=callValue02 # At maturity, the call value is given by terminal condition; e = sp.random.normal(0,1); stockPrice *= math.exp(drift+sigmasqrtdt * e) print("the stock price at maturity is {}".format(stockPrice)) callValue = max(stockPrice-X,0) print("the call value at maturity is {}".format(callValue)) # we can caculated the portfolio value at maturity; moneyAccount *= interest portfolio[j] = moneyAccount+callValue-delta01*stockPrice print("the portfolio at maturity is {}".format(portfolio[j])) # After numMC of Monte Cal portfolioValue =sp.mean(portfolio) return portfolioValueprint("the result from Monte Carlo for delta hedging strategy is {}".format(MC_deltaHedging_Call(100,100,1,0.1,0.1,0.05,1,360)))# Remark: we can NOT make or lose money by using the delta hedging strategy under the assumptions of Black-Sholes model.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 欧美一级免费在线观看 | 久草在线 | 色综合久久88色综合天天6 | 国产精品福利网站 | 天天成人综合网 | 国产第一区二区 | 天天舔天天干 | 97av超碰| 99精品国产视频 | 成年人网站免费在线观看 | 欧美视频在线播放 | 污视频网址在线观看 | 国产精品夜色一区二区三区 | 久草不卡视频 | 狠狠色噜噜狠狠狠狠2018 | 国产一级免费 | www97影院 | 一区二区三区回区在观看免费视频 | 亚洲第一天堂 | 国产一区二区三区91 | 久久精品久久久久久久久久久久久 | 97久久精品午夜一区二区 | www.一区二区三区 | 成人av高清 | 亚洲欧美另类图片 | 精品国产一区二区三区成人影院 | 在线亚洲一区二区 | 色综合久久88色综合天天6 | 风间由美一区二区三区在线观看 | 日韩五码在线 | 国产激情偷乱视频一区二区三区 | 一区二区在线视频观看 | 精品日韩欧美一区二区在线播放 | 99精品久久精品一区二区爱城 | 色小妹三区 | 色网站在线观看 | 国产精品久久九九 | 精品欧美乱码久久久久久 | 美女视频一区 | 青草视频在线观看免费 | 成人在线一区二区 |