The last day of 5.1

       这是五一的最后一天了,呵,不管好还是坏,无聊还是尽兴,都过来了,五一九天的假期,书也看了,如果给自己一个成绩,也就只能说是差吧,因为并没有太多的精力去看书,哎,总想着每天早上早起锻炼身体,这下可好,一直就没有起来过,都有点恨自己不争气了,呵,没办法,人都是有惰性的,我也不例外,虽然一年前在练体的时候有个不错的习惯,可是一年过去了,渐渐的对自己也失去了信心,因为体育对我来说,己经太远了,真的,根本不会太多的去接触它,不会有太大的作为了,就这样,我也就对自己放弃了不少,在这上,可是现在想想,没有一个好的体质,还是不行的,对自己来说是多么的失败,方方面面吧,包括私人的事情,嘿,真点不好意思了,可是毕竟这也是将来生活的一部份,今儿和朋友去了中心,之后又去的西单,买了三件衣服,花了三十元钱,嘿,真爽,虽说衣服不是特好,可是我们三个一起穿还是会有感觉的,又买了三个挂件儿,在西单买东西感觉就是不一样,呵,说也说不清楚,我想只有亲身体会过才会明白! 晚上刚刚才看了一个电影---野蛮秘笈,搞得我现在都有点怀疑,她会不会是我的缘份呢? ! 嘿,也许是自己想多了,再说吧,事情总是在发展的,将来总有一天会知道的,现在我不想去想那么多,代码的事情还是继续,也就是五一过后开始接着我的准职业生涯吧,对了,她过些天就要过到我这住这儿来上班了,呵,不知这又是不是一种缘呢!??? 才也不知是不是自己说错话了,电脑老给我出错,不让我写成,害我现在才弄好,真不容易,气死我了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
To price discrete-monitored barrier options in Python, we can use the Monte Carlo simulation method. Here are the steps to do so: 1. Define the parameters of the option, such as the strike price, barrier level, expiration date, and risk-free interest rate. 2. Generate a large number of random stock price paths using a geometric Brownian motion model. 3. For each stock price path, check if the barrier is breached at any of the monitoring dates. If the barrier is breached, the option expires worthless. Otherwise, the option pays off according to its payoff function (e.g. European call or put option). 4. Calculate the average payoff of all the simulated paths to obtain the option price. To compare the price of the discrete-monitored barrier option with the continuous-time version, we can repeat the above steps but with a different model for the stock price. Instead of using geometric Brownian motion, we can use a continuous-time model such as Black-Scholes. We can then compare the prices obtained from the two models. Here is an example Python code for pricing a discrete-monitored barrier option using Monte Carlo simulation: ```python import numpy as np from scipy.stats import norm # Option parameters s0 = 100 k = 110 b = 120 T = 1 r = 0.05 sigma = 0.2 n = 12 # Number of monitoring dates per year # Monte Carlo simulation parameters num_paths = 100000 num_steps = int(T * n) # Generate stock price paths dt = T / num_steps drift = (r - 0.5 * sigma**2) * dt volatility = sigma * np.sqrt(dt) z = np.random.normal(size=(num_paths, num_steps)) s = s0 * np.exp(np.cumsum(drift + volatility * z, axis=1)) # Check barrier breach at monitoring dates is_breached = np.any(s > b, axis=1) # Calculate option payoff payoff = np.maximum(0, s[:, -1] - k) * (1 - is_breached) # Discounted expected payoff discount_factor = np.exp(-r * T) option_price = discount_factor * np.mean(payoff) print("Discrete-monitored barrier option price:", option_price) ``` To price the continuous-time version using Black-Scholes, we can use the following code: ```python from scipy.stats import norm d1 = (np.log(s0/k) + (r + 0.5 * sigma**2) * T) / (sigma * np.sqrt(T)) d2 = d1 - sigma * np.sqrt(T) n1 = norm.cdf(d1) n2 = norm.cdf(d2) call_price = s0 * n1 - k * np.exp(-r * T) * n2 put_price = k * np.exp(-r * T) * (1 - n2) - s0 * (1 - n1) print("Continuous-time Black-Scholes call price:", call_price) print("Continuous-time Black-Scholes put price:", put_price) ``` We can then compare the prices obtained from the two models to see how much difference the discrete monitoring makes.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值