A random walk in Time Series Modeling

Andrew Carr
Elastic Engineer

About Me

About Me

DevOps

What is Time Series Analysis?

"a collection of observations of well-defined data items obtained through repeated measurements over time"

ABS:Time Series Analysis: The Basics

Etherium Modelling

Overall Approach

 

Etherium Modelling

FastAI Model

##FastAI Tabular Model
#Data Cleaning
def order(x):
  if (x['Close']*1.07 < x['followDayClose']):
    return 'buy'
  if (x['Close'] <= x['followDayClose']):
       return 'hold'
  else: return 'sell'

df['followDayClose'] = df['Close'].shift(-1)
df['order'] = df.apply(order, axis=1)

#`Categorify` will transform columns that are in your `cat_names` into that type, 
 # along with label encoding our categorical data:
to = TabularPandas(df, cat, cat_names)
cats = to.procs.categorify

#Normalize
#To properly work with our numerical columns, we need to show a relationship between them all that our model can understand. 
 #This is commonly done through Normalization, where we scale the data between -1 and 1, and compute a z-score
to = TabularPandas(df, norm,cat_names=cat_names, cont_names=cont_names)
norms = to.procs.normalize

#FillMissing
fm = FillMissing(fill_strategy=FillStrategy.median)
to = TabularPandas(df, fm, cont_names=cont_names, cat_names=cat_names)

#Building DataLoader Object and loading
dls = to.dataloaders()

#Running Training
learn = tabular_learner(dls, [10000,1], metrics=accuracy)
learn.lr_find()

#Export Model
learn.export('/content/drive/MyDrive/Code/ethModel.pkl')

Etherium Modelling

FastAI Model

 

50.3% Accuracy

Etherium Modelling

#Import Dataset which needs to have YYYY-MM-DD date field titled 'DS' and a dependent varible titled 'Y'
df = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/examples/example_wp_log_peyton_manning.csv')

#Instantiate a Prophet Object and call fit on the DataFrame
m = Prophet()
m.fit(df)

#Create a DataFrame with 365 days of future timestamps
future = m.make_future_dataframe(periods=365)

#Take future timestamps and apply model to predict future
forecast = m.predict(future)
fig1 = m.plot(forecast)

Etherium Modelling

 

Trading bot currently running on AWS EC2 within Docker image

Etherium Modelling
Freqtrade

Etherium Modelling
Freqtrade

Etherium Modelling

Problems with tested approaches

 

Approach Positives Negatives
FastAI Tabular Model Easy to implement. Does not suit time series analysis case
Facebook Prophet Great visualization of trends. Failed to work within Freqtrade platform.
Freqtrade Default Strategies Great quick start.
Great interface
Can only access cryptocurrency

Etherium Modelling

Overall find it difficult to find an edge

Time to change market!

Future Plans

More Data and better Trained!

 

Future Plans

Utilisation of FastAI's tsai library

 

Future Plans

Modelling of Commodities

 

 

 

Great Time Series Learning Resources

 

Python for Data Science and Machine Learning Bootcamp
FastAI: Practical Deep Learning

Great Time Series Learning Resources

 

Time Series Forecasting in Python
Marco Peixeiro
Financial markets and software engineering: Part Time Larry (YouTube)

Great Time Series Learning Resources

 

Questions?