Probability of a Touch in Finance using Python Monte Carlo Methods

preview_player
Показать описание
We use Monte Carlo methods with Python to calculate the probability of a stock reaching a given price in a specified amount of time. The code simulates a large number of potential stock prices using the implied volatility to get the width of the normal distribution used to sample random numbers. The code then counts the number of runs where the target price is reached and estimates the probability by taking the ratio of that number with the total number of simulated runs.

Рекомендации по теме
Комментарии
Автор

This is terrifically helpful. Thanks so much. It's got applications well-beyond options trading. Regarding vectorisation, I believe you can replace the initialised 'prices' matrix and the for-loop (beginning around 8m.19s in the vid, and line 19 - 30 in your GitHub code) with:

p = s0 * (1 + ds_s).cumprod(axis = 1)

where p is the 'prices' matrix and s0 is the starting stock price. I'm also pretty sure that to anchor the plot at 196.8, you can use np.concatenate() to add that column to p. Thoughts on this are welcome. Thanks again. Your videos are extremely helpful.

rsbenari
Автор

Thanks, can u plz do this in excel sheet as well because I don't know how to use python

mangeshw
Автор

What do you think about this variant in order to calculate the probability that the last prices of the simulation series are above a given value (160.0):

last_prices = prices[:, len(prices[0])-1]

ind = np.where(last_prices >= 160.0)
U = np.unique(ind[0])
print('\nPercentage of reached goal simulations: ', float(len(U)) / float(samples))


Then if I combine it with the option premium I can calculate the probability to have profitable payoff at the exercise. I could also use to determinare profit probabilities for straggles and straddles.

TheChievovr
welcome to shbcf.ru