Forecasting bitcoin returns with Prophet in Python-Part I
Working with timeseries can be very time consuming, especially when you have to iteratively run through a range of different parameterisations and models. So, when I learned about the Prophet package for Python, I was quite interested to have a good look at it.
How to set up Prophet
After installing Prophet, the package does all the work for you and you only have to do a couple of things. In my case I had to install the Anaconda package first, before I got it to work. More on the installation process can be found here. So, here is what you need to do once the package is installed.
- define model inputs
- rename variables such that Prophet recognises them
- write the instructions that kick off the model fitting process
In Python this looks like:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from fbprophet import Prophet
import pandas_profiling as pp
import matplotlib.pyplot as plt
from fbprophet import Prophet
df_fullset = pd.read_csv("<insert location of your dataset>")
df_model=pd.DataFrame()
df_model['y']=df_fullset['Ret']
df_model['ds']=df_fullset['timestamp']
m = Prophet()
m.fit(df_model)
future = m.make_future_dataframe(periods=150)
forecast = m.predict(future)
fig1 = m.plot(forecast)
fig2 = m.plot_components(forecast)
plt.show()