Histogrammes

Introduction à Python pour la finance

Adina Howe

Instructor

Pourquoi utiliser des histogrammes pour l'analyse financière ?

histogram

Introduction à Python pour la finance

Histogrammes et données

  • Vos données sont-elles biaisées ?
  • Vos données sont-elles centrées autour de la moyenne ?
  • Vos données contiennent-elles des points anormaux (valeurs aberrantes) ?
Introduction à Python pour la finance

Histogrammes et matplotlib.pyplot

import matplotlib.pyplot as plt
plt.hist(x=prices, bins=3)
plt.show()

hist1

Introduction à Python pour la finance

Modification du nombre de catégories

import matplotlib.pyplot as plt
plt.hist(prices, bins=6)
plt.show()

hist2

Introduction à Python pour la finance

Normalisation des données de l'histogramme

import matplotlib.pyplot as plt
plt.hist(prices, bins=6, normed=1)
plt.show()

normed

Introduction à Python pour la finance

Superposition d'histogrammes sur un graphique

import matplotlib.pyplot as plt
plt.hist(x=prices, bins=6, normed=1)
plt.hist(x=prices_new, bins=6, normed=1)
plt.show()
Introduction à Python pour la finance

Résultat de l'histogramme

two_hist_normed

Introduction à Python pour la finance

Alpha : Modification de la transparence des histogrammes

import matplotlib.pyplot as plt
plt.hist(x=prices, bins=6, normed=1, alpha=0.5)
plt.hist(x=prices_new, bins=6, normed=1, alpha=0.5)
plt.show()
Introduction à Python pour la finance

Résultat de l'histogramme

two-hist-transparent

Introduction à Python pour la finance

Ajouter une légende

import matplotlib.pyplot as plt
plt.hist(x=prices, bins=6, normed=1, alpha=0.5, label="Prices 1")
plt.hist(x=prices_new, bins=6, normed=1, alpha=0.5, label="Prices New")
plt.legend()
plt.show()
Introduction à Python pour la finance

Résultat de l'histogramme

pretty hist

Introduction à Python pour la finance

Passons à la pratique !

Introduction à Python pour la finance

Preparing Video For Download...