13.08.2022 Views

advanced-algorithmic-trading

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

298

label=’Avg Test MSE’

)

ax.legend(loc=0)

ax.set_xlabel(’Degree of Polynomial Fit’)

ax.set_ylabel(’Mean Squared Error’)

fig.set_facecolor(’white’)

plt.show()

def plot_test_error_curves_kf(kf_dict, folds, degrees):

fig, ax = plt.subplots()

ds = range(1, degrees+1)

for i in range(1, folds+1):

ax.plot(

ds,

kf_dict["fold_%s" % i],

lw=2,

label=’Test MSE - Fold %s’ % i

)

ax.plot(

ds,

kf_dict["avg"],

linestyle=’--’,

color="black",

lw=3,

label=’Avg Test MSE’

)

ax.legend(loc=0)

ax.set_xlabel(’Degree of Polynomial Fit’)

ax.set_ylabel(’Mean Squared Error’)

fig.set_facecolor(’white’)

plt.show()

if __name__ == "__main__":

symbol = "AMZN"

start_date = datetime.datetime(2004, 1, 1)

end_date = datetime.datetime(2016, 10, 27)

lags = create_lagged_series(

symbol, start_date, end_date, lags=10

)

# Use ten prior days of returns as predictor

# values, with "Today" as the response

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!