5

Here is a simple example that might be useful. Basically finding parameters for a given section. Some of the parameters might be assumed at start instead of calibrated. import QuantLib as ql import matplotlib.pyplot as plt import numpy as np from scipy.optimize import minimize strikes = [105, 106, 107, 108, 109, 110, 111, 112] fwd = 120.44 expiryTime = 17/...


4

You are missing a few things. The function below assumes that returns is either a pandas series or a column of a pandas dataframe. Try this: def MDD(returns): cum_rets = (1 + returns).cumprod() - 1 nav = ((1 + cum_rets) * 100).fillna(100) hwm = nav.cummax() dd = nav / hwm - 1 return min(dd)


3

The constructor of GarmanKohlagenProcess takes a Handle, so if you really want to avoid it you'll have to modify the constructor (and the type of the corresponding data member it initializes).


3

A test for arbitrage opportunities with an LP is to minimize the cost of setting up the portfolio, subject to the restriction that the portfolio loses money in no state of the world. (Note that in your formulation you are missing the actual objective; you only list constraints.) If you find a portfolio that has a negative cost (i.e. you get paid for holding ...


3

QuantLib does have an FD pricing engine for asian options ql.FdBlackScholesAsianEngine(stochProcess, tGrid=100, xGrid=100, aGrid=50), but I've just discovered it only prices Discrete, Arithmetic payoffs! Moving from Continuous to Discrete (documented here) doesn't change the price of the option much, if you pass in something like asianFixingDates = [ql....


3

The price close to 0.93 is correct, here is a reimplementation of both FD and analytic using QuantLib: import QuantLib as ql # World State for Vanilla Pricing spot = 50 vol = 0.2 rate = 0.01 dividend = 0.0 today = ql.Date(1, 9, 2020) day_count = ql.Actual365Fixed() calendar = ql.NullCalendar() # Set up the vol and risk-free curves volatility = ql....


2

Though your code is already giving you the correct result, I almost feel bad for you that you have to wait 5 seconds for such a small amount of data. Your code is slow because you are kind of reinventing the wheel instead of using some built-in pandas and numpy functionality. For example, product and wma in your code can be combined and accomplished using ...


2

I can't quite even re-create your vol smile... when I plug in the parameters you've provided (at $\tau = 0.12$) I get a downward sloping vol smile that doesn't have a minimum at the strikes I looked at I then backed out the options prices at each of a close-up grid of strikes and calculated the curvature of the prices, which is very close to the rn pdf (...


1

Echoing @noob2 's comments. Additionally, one of the things you might want to be aware of is there is a time to maturity difference between VIX and your calculation of historical volatility. While you are using a constant time frame (30 day) for your volatility calculation, VIX utilizes the near term options contracts for its calculation. As options have ...


1

I googled and found https://github.com/TommasoBelluzzo/BaselTools . It says: BaselOP The tool can be run by executing the BaselOP.m script. The underlying calculations are based on the SMA model defined within the BCBS 356. The application offers the opportunity to compare the SMA capital requirements with those produced by the obsolete Basel II approaches ...


1

Let's see. You have the following SDE for the stock price under the measure $P$: $$ dS(t) = \alpha \cdot (\mu - \log S(t)) \cdot S(t) \cdot dt + \sigma \cdot S \cdot dW^P(t), $$ with initial condition $S(0) = S_0$. Moreover, defining $X(t) = \log S(t)$, assuming a constant market price of risk $\lambda = \mu - r$ and performing a change of measure, you get ...


1

You will need to change the payoff from: payoff = ql.PlainVanillaPayoff(ql.Option.Call, strike_price) to payoff = ql.CashOrNothingPayoff(ql.Option.Call, strike_price, 1)


1

A few things... firstly, I've attached a correction to your code at the bottom. It runs, but gives a solution of 0.0. Not sure why that is, but the code runs at least, can you work out the pricing problem yourself? You've used the import * pattern here. It seems easy now, but it will cause you trouble in future, because when you come to work out where each ...


1

Using MC Simulation, if I am trying to price Geometric Average Asian Option by running the following code: import QuantLib as ql today = ql.Settings.instance().evaluationDate averageType = ql.Average.Geometric option_type = ql.Option.Call strike = 100.0 exerciseDate = ql.TARGET().advance(today, 90, ql.Days) pastFixings = 0 # Empty because this is a new ...


1

I found the answer - could be useful for someone else :) from scipy.optimize import least_squares, curve_fit, minimize, leastsq, shgo, fmin_cg def seasonality(coeff,t,y): a = coeff[0] b = coeff[1] c1 =coeff[2] c2 =coeff[3] d1 = coeff[4] d2 = coeff[5] return y - a - (b*t) - c1*np.sin(2*math.pi*t) - c2*np.cos(2*math.pi*t) - d1*np....


Only top voted, non community-wiki answers of a minimum length are eligible