Created
December 13, 2017 17:22
-
-
Save memonkey01/abfb326d924a481a2f5b100ae74ed52b to your computer and use it in GitHub Desktop.
BlackScholes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Black-Scholes | |
Autor: Guillermo Izquierdo | |
Este código es para fines educativos exclusivamente | |
""" | |
from math import log, sqrt, exp | |
from scipy import stats | |
#Definimos nuestros parametros iniciales | |
S = 102 | |
E = 100 | |
T = 1 | |
r = 0.05 | |
sigma = 0.25 | |
#Definimos la opción Call bajo la ecuación de BlackScholes | |
d1 = (log(S/E))+((r + 0.5 * sigma ** 2) * T) / (sigma * sqrt(T)) | |
d2 = (log(S/E))+((r - 0.5 * sigma ** 2) * T) / (sigma * sqrt(T)) | |
V = (S * stats.norm.cdf(d1, 0, 1)) - (E * exp(-r * T) * stats.norm.cdf(d2, 0, 1)) | |
#Imprimimos el resultado en pantalla | |
print('El precio de la opcion call es: {}'.format(V)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment