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
def prob_default(ticker): | |
""" DEFINING THE FUNCTION WE WANT TO OPTIMISE""" | |
def fun(x): | |
va=x[0] | |
siga=x[1] | |
d1=(np.log(va/X)+(r+0.5*siga**2)*T)/(siga*np.sqrt(T)) | |
d2=d1-siga*np.sqrt(T) | |
return [va*norm.cdf(d1)-X*np.exp(-r*T)*norm.cdf(d2)-ve,va*norm.cdf(d1)*siga/ve-sige] | |
"""DATA SELECTION""" | |
start_date='2018-01-01' |
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
scaler = StandardScaler() | |
df=scaler.fit_transform(df) | |
kmeans_kwargs = {"init": "random","n_init": 20,"max_iter": 1000,"random_state": 1984} | |
cut_off=0.5 | |
maxvars=3 | |
kmin=2 | |
kmax=8 | |
cols=list(df.columns) |
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
from sklearn.preprocessing import StandardScaler | |
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
import random | |
import seaborn as sns | |
from sklearn.preprocessing import StandardScaler | |
# We define a function returning the centroid of a set of points and the distance between two points |