import yfinance as yf
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.api as sm
from pmdarima import auto_arima
df = yf.download(tickers = 'GC=F', start = '2016-08-25', end = '2021-08-25')
df = df.dropna()
best_order = auto_arima(df['Close'], trace= True)
# Best model: ARIMA(0,1,0)(0,0,0)[0]
columns = ['Close']
df = pd.DataFrame(df, columns = columns)
train, test = df[0: int(len(df) * 0.85)], df[int(len(df) * 0.85):]
model = sm.tsa.arima.ARIMA(train, order= (0,1,0))
model = model.fit()
#printing predictions for next 30 days
index_future_dates=pd.date_range(start='2021-08-26',end='2021-09-25')
#print(index_future_dates)
pred=model.predict(start=len(df),end=len(df)+30,typ='levels').rename('ARIMA Predictions')
#print(comp_pred)
pred.index=index_future_dates
print(pred)
2021-08-26 1872.599976 2021-08-27 1872.599976 2021-08-28 1872.599976 2021-08-29 1872.599976 2021-08-30 1872.599976 2021-08-31 1872.599976 2021-09-01 1872.599976 2021-09-02 1872.599976 2021-09-03 1872.599976 2021-09-04 1872.599976 2021-09-05 1872.599976 2021-09-06 1872.599976 2021-09-07 1872.599976 2021-09-08 1872.599976 2021-09-09 1872.599976 2021-09-10 1872.599976 2021-09-11 1872.599976 2021-09-12 1872.599976 2021-09-13 1872.599976 2021-09-14 1872.599976 2021-09-15 1872.599976 2021-09-16 1872.599976 2021-09-17 1872.599976 2021-09-18 1872.599976 2021-09-19 1872.599976 2021-09-20 1872.599976 2021-09-21 1872.599976 2021-09-22 1872.599976 2021-09-23 1872.599976 2021-09-24 1872.599976 2021-09-25 1872.599976