# Tag Info

5

Something like this? from mpl_toolkits import mplot3d from itertools import product S = np.linspace(100,120) vols = np.linspace(0.05,0.7) combs = list(product(S, vols)) values = [Vanna_(underlying, K, T, r, sigma) for underlying, sigma in combs] x, y = np.hsplit(np.array(combs), 2) fig = plt.figure() ax = plt.axes(projection="3d") ax.scatter3D(x,...

4

When we worked with that model several years go, we used Differential Evolution and it worked very well. See Calibrating the Nelson-Siegel-Svensson Model. At least in the standard version, a best-of-many gradient searches (with random initial values) also worked well. See A Note on 'Good Starting Values' in Numerical Optimisation. If you were willing to use ...

3

An answer with R and pseudo-code: As pointed out by @markleeds, there is no need for two for-loops, since you can vectorize the outer loop. You only need the last for-loop if you want to do rolling Roger-Satchell volatility estimates. I cannot code in Go, but I can provide you with some pseudo-code. Let your OHLC data be defined as \$X \in \mathbb{R}^{T\times ...

3

Here is another solution using Plotly. First of all let me correct a typo in your code def Vanna_(S, K, T, r, sigma): lista = [] d1 = (np.log(S / K) + (r + 1/2 * sigma ** 2) * T) / (sigma * np.sqrt(T)) d2 = d1-sigma*T**(1/2) return (1 / np.sqrt(2 * np.pi) * S * np.exp(-d1 ** 2 * 1/2) * np.sqrt(T))/S * (1- d1/(sigma*np.sqrt(T))) Then let me ...

3

Amortization is included when you build the bond. Given that you're mentioning a payment of 300, I'll guess that your face amount is 1000, not 100 as you wrote. Also, you're mentioning a payment on 30.04.2018, but your schedule starts on 02.12.2019. For the purpose of the example, I'll start the schedule earlier so it includes both payments. So, let's say ...

2

Edit: You need to specify the keyword arguments in your second example The poor calibration of your second example comes from the fact, that you didn't define the keyword arguments in the LNsabr-object before the .fit() function. Instead of writing: calibration_LN = LNsabr(forward_3m_6m, 0, 0.5, beta).fit(strikes, LogNormalVols) You only need to make the ...

2

Did you try the differences? You can check out logarithmic properties in this answer. Specifically, Reason 2: The log difference is independent of the direction of change If you code it, you see that the logarithmic return for $$-1*log(p_1/p_0) = log(p_0/p_1)$$ p0 = 100 p1 = 101 retPos = p1/p0-1 retNeg = 1-p1/p0 retLogPos = log(p1/p0) retLogNeg = log(p0/...

2

VanillaSwap models simple swaps, so it doesn't have a lot of bells and whistles. For more control, you can create the two legs separately and use the Swap class. In your case: fixed_leg = ql.FixedRateLeg(fixedSchedule, fixedLegDayCount, [notional], [fixedRate]) floating_leg = ql.IborLeg([notional], floatSchedule, floatIndex, floatLegDayCount, ...

2

With end-of-month set to False, the schedule doesn't even try to hit the 31st; it starts from a stub on the 30th, so it uses the 30th of the month for all other dates. Unfortunately, as you say, you can't set end-of-month to True in this case; so you'll probably have to use the Schedule constructor that takes an explicit list of dates (you can generate them ...

2

Your end goal of obtaining "fair" theoretical option prices will unfortunately require a lot of effort if you want to get this done properly on your own. Here are a few reasons why: All Nasdaq marketplace stock options are American-style IVOL exhibits a skew You need to have reliable interest rates Dividend assumptions will influence your pricing ...

1

Assuming you aren't reinvesting the dividend in the stock, your YTD return would just be the price on date nplus the dividends received up to that date divided by the initial price: ytd_return = (price_n + div_ytd) / price_0

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