BaşlayınÜcretsiz Başlayın

Plot returns

Lastly, we'll plot the performance of our machine-learning-generated portfolio versus just holding the SPY. We can use this as an evaluation to see if our predictions are doing well or not.

Since we already have algo_cash and spy_cash created, all we need to do is provide them to plt.plot() to display. We'll also set the label for the datasets with legend in plt.plot().

Bu egzersiz

Machine Learning for Finance in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Use plt.plot() to plot the algo_cash (with label 'algo') and spy_cash (with label 'SPY').
  • Use plt.legend() to display the legend.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Plot the algo_cash and spy_cash to compare overall returns
plt.plot(____, ____)
plt.plot(spy_cash, label='SPY')
____  # show the legend
plt.show()
Kodu Düzenle ve Çalıştır