python barrier option pricing_C++量化金融开发库

Changes for QuantLib 1.12:

QuantLib 1.12 includes 54 pull requests from several contributors.

The most notable changes are included below. A detailed list of changes is available in ChangeLog.txt and at https://github.com/lballabio/QuantLib/milestone/7?closed=1.

Portability

As announced in the previous release, support for the Dev-C++ IDE was removed.

In April 2018, Microsoft will end its support for Microsoft Visual C++ 2008. Therefore, this is the last version of QuantLib to support it with maintained project files. The next release will only contain project files for Visual C++ 2010 and later.

It is now possible to build a usable library with CMake on Windows (thanks to Javier G. Sogo).

Fix autotools build outside the source tree (thanks to Joshua Ulrich).

Instruments and pricing engines

Added OAS calculation to experimental callable bonds (thanks to Bojan Nikolic).

Avoided infinite loop for some sets of parameters in experimental variance-gamma engine (thanks to Roy Zywina).

Cash flows

It is now possible to build a cash-flow leg from a schedule created from a precalculated vector of dates (thanks to Peter Caspers).

Models

Affine models can now be used to bootstrap a default-probability curve (thanks to Jose Aparicio).

Added Andreasen-Huge volatility interpolation and local volatility calibration (thanks to Klaus Spanderen).

Added Rannacher smoothing steps for Heston stochastic local volatility calibration (thanks to Klaus Spanderen).

Term structures

Added L2 penalty to fitted parameters of fitted bond discount curve (thanks to Robin Northcott).

Added an optional trading calendar to the FX-swap rate helper and and optional payment lag to the OIS rate helper (thanks to Wojciech Slusarski).

Fixed inconsistent treatment of strike in experimental CPI cap/floor term price surface (thanks to Francis Duffy).

Correctly handled the case of overlapping strike regions for caps and floors in experimental CPI cap/floor term price surface (thanks to Peter Caspers).

Fixed calculation of seasonality correction for interpolated inflation indexes (thanks to Francis Duffy).

Implemented composite zero-yield curve as combination of two existing curves via a given binary function (thanks to Francois Botha).

Fixed interpolation of shift in swaption volatility matrix (thanks to Peter Caspers).

Date/time

Updated Chinese calendar for 2018 (thanks to Cheng Li).

Added Botswana calendar (thanks to Francois Botha).

Fixed a few problems with US calendars (thanks to Mike DelMedico and to GitHub user ittegrat).

User-added holidays now work correctly when intraday calculations are enabled (thanks to Klaus Spanderen for the fix and to GitHub user volchemist for the report).

Math

Fixed monotonicity of Fritsch-Butland and prevented NaNs in some cases (thanks to GitHub user Grant6899 for the fix and to Tom Anderson for the report).

Deprecated features

The ChiSquareDistribution, NonCentralChiSquareDistribution, InverseNonCentralChiSquareDistribution and GammaDistribution were renamed to CumulativeChiSquareDistribution, NonCentralCumulativeChiSquareDistribution, InverseNonCentralCumulativeChiSquareDistribution and CumulativeGammaDistribution, respectively (thanks to GitHub user IGonza). The old names are still available as typedefs and will be removed in a future release.

Thanks go also to Marco Craveiro, Dirk Eddelbuettel, Lakshay Garg, Guillaume Horel, Alix Lassauzet, Patrick Lewis, and GitHub users bmmay, bingoko and tournierjc for smaller fixes and enhancements.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
To price a barrier option on FX rate by Monte Carlo simulation, you can follow these steps: 1. Define the basic parameters of the barrier option, including the spot FX rate, strike price, option expiration date, barrier level, barrier type (up/down), barrier monitoring frequency, volatility, and risk-free rate. Store these parameters in variables. 2. Generate the simulated FX rate paths. Use a random number generator (such as the normal distribution) to generate a set of random shocks to the FX rate at each time step. Use these random shocks to simulate a set of possible FX rate paths for the option's life. Store these paths in a matrix. 3. Determine if the barrier has been breached for each simulated path. At each monitoring frequency, check if the FX rate has crossed the barrier level. If it has, take note of the time and location of the first breach. 4. Calculate the payoff for each simulated path. If the FX rate breached the barrier before the option expiration, the option expires worthless. If the FX rate did not breach the barrier before the option expiration, the option payoff is the maximum of 0 and the difference between the FX rate and the strike price. 5. Discount the payoff to the present value. Use the risk-free rate and the option's time to expiration to calculate the discount factor and present value for each simulated path. 6. Calculate the option price. Take the average of all the present values calculated in step 5 to get the option price. Here's an example of how to implement these steps in Python: ```python import numpy as np # Define basic parameters S0 = 1.2 # Spot FX rate K = 1.3 # Strike price T = 1 # Time to expiration B = 1.1 # Barrier level barrier_type = 'up' # Barrier type monitoring_freq = 10 # Barrier monitoring frequency sigma = 0.2 # Volatility r = 0.05 # Risk-free rate N = 10000 # Number of simulations dt = 1/252 # Time step # Generate the simulated FX rate paths ST = np.zeros((N, monitoring_freq+1)) ST[:,0] = S0 for i in range(N): for j in range(1, monitoring_freq+1): ST[i,j] = ST[i,j-1] * np.exp((r-sigma**2/2)*dt + sigma*np.sqrt(dt)*np.random.normal()) # Determine if the barrier has been breached for each simulated path breached = np.zeros(N, dtype=bool) time_to_breach = np.zeros(N) for i in range(N): for j in range(1, monitoring_freq+1): if barrier_type == 'up': if ST[i,j] > B: breached[i] = True time_to_breach[i] = j break else: if ST[i,j] < B: breached[i] = True time_to_breach[i] = j break # Calculate the payoff for each simulated path payoff = np.zeros(N) for i in range(N): if breached[i]: payoff[i] = 0 else: payoff[i] = max(0, ST[i,-1] - K) # Discount the payoff to the present value df = np.exp(-r*T) pv = payoff * df # Calculate the option price price = np.mean(pv) ``` This code generates random FX rate shocks at each time step to simulate possible FX rate paths for the option's life. It then checks if the barrier is breached for each path and calculates the payoff for each path. Finally, it discounts the payoff to the present value and calculates the option price as the average present value across all paths. Note that this is a simplified example and more advanced techniques may be required to get accurate option prices.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值