# Tag Info

## New answers tagged programming

3

Assuming that your GBM is given by $$S_{T}=S_{0}e^{(r -{\frac {\sigma ^{2}}{2}})T+\sigma W_{T}}$$ then its mean and variance are: $${Mean=S_{0}e^{r T},}$$ $${Variance=S_{0}^{2}e^{2r T}\left(e^{\sigma ^{2}T}-1\right)}{\displaystyle}$$ You cannot paste these values directly into np.random.lognormal because in this case the parameters $\mu$ and $\sigma^2$ ...

4

I started with "Pandas for Data Analysis" by Wes Mckinney (the original developer of pandas) without ever using Python before. After 3yrs I have the skills of a full stack developer, after some other projects using for example "Flask for Web Development" by Miguel Grinberg which is nice project for getting familiar with databases and SQLAlchemy class ...

2

Try Hilpisch's books, especially Python for Finance. For derivatives pricing specifically, he wrote Derivatives Analytics with Python. Hope that helps.

4

Discount vs forward estimation curve The YieldTermStructureHandle passed to BlackCapFloorEngine corresponds to the discount curve, while the one passed to IborIndex corresponds to the forward estimation curve In the example you are referring two, it turns out both are identical, but you could very well define two different handles on two different curves, ...

1

Yes. You should use that function to calculate the implied volatility - market convention is to always quote implied volatility using the Black-Scholes model. Traders may execute a trade simply by agreeing a level of implied volatility combined with the use of the corresponding Bloomberg option pricing page. Someone once said, "it is the wrong number in ...

1

When you here implied volatility in finance, it usually means Black volatility or Bachelier volatility. In your case, since you have the prices from Heston, you can use Black-scholes to get the implied volatility. In that scenario, don't think about Black-scholes as a model, but as a translator to better understand the option price. For option traders, ...

5

The issue is that you do not plot one sample path but for each time point $t$, you simply plot one possible realisation of the random variable $S_t(\omega)$. Thus, you don't get a connected path. (Just as a minor, you would need brackets in the exponential in your for loop, i.e. X_analytic[i] <- X_analytic[1]*exp((mu - 0.5*sigma^2)*time[i] + sigma*Z[i-1]...

2

There does not exist a single metric that encompasses all your criteria; but you could simply construct a (linear or non-linear) combination of the measures you like. For the win/loss streaks you describe, you could either look at the absolute maximum drawdown of the cumulative series (1 in the first case, 3 in the second), or look at streaks and penalise ...

0

You are observing the same underlying $S_t$, therefore it has to be one set of parameters for all maturities. You could add a term structure to the parameters , however , since you are using SABR, I assume you use Hagan expansion to generate the implied vols, and for this approximation, the parameters must be constant.

2

The formula for pricing a swaption under normal volatility is simply the Bachelier formula. It may be found in many papers (for example, Le Floc'h Fast and accurate basis point volatility), and is also on stackoverflow. You can easily move from a payer ($C$) to a receiver ($P$) by using the put-call parity relationship:  C(t) - P(t) = B(t,T) (F(t,T)-K)\,,$... 2 what you are doing is not really an application of the central limit theorem (CLT) but rather an application of the law of large numbers. If I understood your problem correctly you start with the following information: The future discounting rate has a uniform distribution:$r \sim U(1\%, 20\%)$. The future capital has a uniform distribution:$k \sim U(500, ...

4

Approximating implied volatility of European options can be done in a few ways--this is just one. Below is a python implementation that uses Newton Raphson. You can use the implied_volatility function to find the approximate implied volatility. You can then check it by plugging the output from that back into the option_price function. import numpy as np ...

Top 50 recent answers are included