Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
Last active November 6, 2020 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuyasugano/6d78208177a94921ef765c3232a3b00b to your computer and use it in GitHub Desktop.
Save yuyasugano/6d78208177a94921ef765c3232a3b00b to your computer and use it in GitHub Desktop.
Coefficient variable to compare your crypto assets
import matplotlib.pyplot as plt
import seaborn as sns
now = datetime.datetime.utcnow()
path = 'data/' + 'coefficientVariable_' + now.strftime('%Y%m%d_%H%M%S') + '.png'
# seaborn drawing
sns.set_style('whitegrid')
sns.set_palette("PuBu", 8)
sns.set_context(context='paper', font_scale=2, rc=None)
# Coefficient of variation per asset
fig = plt.figure(figsize=(15, 7))
ax = fig.add_subplot(1, 1, 1)
# calculate coefficient of variation,
# represents the ratio of the standard deviation to the mean
cv = pd.DataFrame(df_.std()/df_.mean())
cv.columns = ['Coef']
ax.set_title('Coefficient of variation per crypto asset')
sns_plot = sns.barplot(data=cv.T)
figure = sns_plot.get_figure()
figure.savefig(path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment