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
color_pie = ['Grey', 'Purple', 'Blue', 'Green', 'Orange', 'Red', 'Yellow', 'magenta', 'cyan'] | |
color_pie_dict = dict(zip(df_weights_circle.columns, color_pie)) | |
fig, axes = plt.subplots(2, 2, figsize=(15, 10)) | |
for i, (idx, row) in enumerate(df_weights_circle.iterrows()): | |
ax = axes[i//2, i%2] | |
row = row[row.gt(row.sum() * .01)] | |
ax.pie(row, labels=row.index, colors=[color_pie_dict.get(i) for i in row.index], startangle=30) | |
ax.set_title(idx) |
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
data_2021= yf.download(cryptocurrency, start="2020-12-31", end="2021-12-31")['Adj Close'] | |
[*********************100%***********************] 9 of 9 completed | |
data_2021.head() |
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
return_data_2021 = data_2021.pct_change() | |
cum_daily_return = (1 + return_data_2021).cumprod() | |
var_matrix_2021 = return_data_2021.cov() | |
var_matrix_2021.head() |
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
individual_rets_2021 = data_2021.resample('Y').last().pct_change().mean() | |
result_2021 = pd.DataFrame() | |
for i in range(df_weights_circle.shape[0]): | |
weight = np.array(df_weights_circle.iloc[i]) | |
ret = (np.dot(weight, individual_rets_2021)) | |
vol = np.sqrt(np.dot(weight.T,np.dot(var_matrix*252,weight))) | |
result_2021 = result_2021.append(pd.Series([ret, vol]).rename(df_weights_circle.iloc[[i]].index[0]).to_frame().T) | |
result_2021.columns = ['Returns', 'Volatility'] | |
result_2021 |
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
fig, axs = plt.subplots(figsize=(15,10)) | |
(cum_daily_return.multiply(weights_min_vol, axis=1).sum(axis=1) - 1).plot(label = 'Minimum volatility') | |
(cum_daily_return.multiply(weights_opt_sr, axis=1).sum(axis=1) - 1).plot(label = 'Maximum Sharp') | |
(cum_daily_return.multiply(weights_div, axis=1).sum(axis=1) - 1).plot(label = 'Maximum Diversification') | |
(cum_daily_return.multiply(weights_max_ret, axis=1).sum(axis=1) - 1).plot(label = 'Maximum Returns') | |
plt.title('2021 year') | |
plt.ylim(0) |
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
import pandas as pd | |
import numpy as np | |
import seaborn as sns | |
from scipy.stats import mannwhitneyu | |
from scipy.stats import ttest_ind | |
from scipy.stats import norm | |
from scipy.stats import shapiro | |
from scipy.stats import levene | |
from scipy.stats import normaltest |
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 get_bootstrap( | |
data_column_1, # numeric values of the first sample | |
data_column_2, # numeric values of the second sample | |
boot_it = 10000, # number of bootstrap subsamples | |
statistic = np.mean, # statistics of interest to us | |
bootstrap_conf_level = 0.95 # significance level | |
): | |
boot_len = max([len(data_column_1), len(data_column_2)]) | |
boot_data = [] | |
for i in range(boot_it): # extracting subsamples |
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
game = pd.read_csv('NameOfGames.csv', skiprows=1) | |
game.head() |
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
game.info() |
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
# Rewarded Videos Ads Watched | |
rvaw = game[['A', 'B']][:642] | |
# Interstitial Ads Watched | |
iaw = game[['A.1', 'B.1']][:839] | |
iaw.columns = ['A', 'B'] | |
# User Progress Level | |
upl = game[['A.2', 'B.2']][:2115] | |
upl.columns = ['A', 'B'] |