Skip to content

Latest commit

 

History

History
 
 

prediction_techniques

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

PREDICTION TECHNIQUES

This menu aims to predict the share price of a pre-loaded stock, and the usage of the following commands along with an example will be exploited below.

  • sma
    • simple moving average
  • knn
    • k-Nearest Neighbors
  • linear
    • linear regression (polynomial 1)
  • quadratic
    • quadratic regression (polynomial 2)
  • cubic
    • cubic regression (polynomial 3)
  • regression
    • regression (other polynomial)
  • arima
    • autoregressive integrated moving average
  • prophet
    • Facebook's prophet prediction
  • mlp
    • MultiLayer Perceptron
  • rnn
    • Recurrent Neural Network
  • lstm
    • Long-Short Term Memory

Note: Use this at your own discretion. All of these prediciton techniques rely solely on the closing price of the stock. This means that there are several factors that the models aren't aware of at the time of prediction, and may - drastically - move the price up or down. Examples are: news, analyst price targets, reddit post, tweets from Elon Musk, and so on.

sma

usage: sma [-l N_LENGTH] [-d N_DAYS]

Simple Moving Average:

  • -l : length of SMA window. Default 20.
  • -d : prediciton days. Default 5.

sma

knn

usage: knn [-i N_INPUTS] [-d N_DAYS] [-j N_JUMPS] [-n N_NEIGHBORS]

k-Nearest Neighbors:

  • -i : number of days to use for prediction. Default 40.
  • -d : prediciton days. Default 5.
  • -j : number of jumps in training data. Default 1.
  • -n : number of neighbors to use on the algorithm. Default 20.

knn

linear

usage: linear [-i N_INPUTS] [-d N_DAYS] [-j N_JUMPS]
usage: regression -p 1 [-i N_INPUTS] [-d N_DAYS] [-j N_JUMPS]

Linear Regression (p=1):

  • -i : number of days to use for prediction. Default 40.
  • -d : prediciton days. Default 5.
  • -j : number of jumps in training data. Default 1.

linear

quadratic

usage: quadratic [-i N_INPUTS] [-d N_DAYS] [-j N_JUMPS]
usage: regression -p 2 [-i N_INPUTS] [-d N_DAYS] [-j N_JUMPS]

Quadratic Regression (p=2):

  • -i : number of days to use for prediction. Default 40.
  • -d : prediciton days. Default 5.
  • -j : number of jumps in training data. Default 1.

quadratic

cubic

usage: cubic [-i N_INPUTS] [-d N_DAYS] [-j N_JUMPS]
usage: regression -p 3 [-i N_INPUTS] [-d N_DAYS] [-j N_JUMPS]

Cubic Regression (p=3):

  • -i : number of days to use for prediction. Default 40.
  • -d : prediciton days. Default 5.
  • -j : number of jumps in training data. Default 1.

cubic

regression

usage: regression -p N_POLYNOMIAL [-i N_INPUTS] [-d N_DAYS] [-j N_JUMPS]

Regression:

  • -i : number of days to use for prediction. Default 40.
  • -d : prediciton days. Default 5.
  • -j : number of jumps in training data. Default 1.
  • -p : polynomial associated with regression. Required.

regression

arima

usage: arima [-d N_DAYS] [-i {aic,aicc,bic,hqic,oob}] [-s] [-r] [-o S_ORDER]

Auto-Regressive Integrated Moving Average:

  • -d : prediciton days. Default 5.
  • -i : information criteria - used if auto_arima library is invoked. Default aic.
  • -s : weekly seasonality flag. Default False.
  • -r : results about ARIMA summary flag. Default False.
  • -o : arima model order. If the model order is defined, auto_arima is not invoked, deeming information criteria useless.
    Example: -o 514, where:
    • p = 5 : order (number of time lags) of the autoregressive model.
    • d = 1 : degree of differencing (the number of times the data have had past values subtracted).
    • q = 4 : order of the moving-average model.

arima

prophet

usage: fbprophet [-d N_DAYS]

Facebook's Prophet:

  • -d : prediciton days. Default 5.

prophet

mlp

usage: mlp [-d N_DAYS] [-i N_INPUTS] [-j N_JUMPS] [-e N_EPOCHS] [-p {normalization,standardization,none}] 
[-o {adam,adagrad,adadelta,adamax,ftrl,nadam,optimizer,rmsprop,sgd}] [-l {mae,mape,mse,msle}]

MulitLayer Perceptron:

  • -d : prediciton days. Default 5.
  • -i : number of days to use for prediction. Default 40.
  • -j : number of jumps in training data. Default 1.
  • -e : number of training epochs. Default 200.
  • -p : pre-processing data. Default normalization.
  • -o : optimization technique. Default adam.
  • -l : loss function. Default mae.

Due to the complexity of defining a model through command line, one can define it in: config_neural_network_models.txt

MultiLayer_Perceptron \
    = [ {'Dense': 
                {'units':50, 'activation':'relu'} },
        {'Dense': 
                {'units':100, 'activation':'relu'} },
        {'Dense': 
                {'units':80, 'activation':'relu'} },
        {'Dense': 
                {'units':30, 'activation':'relu'} },
        {'Dense': 
                {'activation':'linear'} }]

mlp

rnn

usage: rnn [-d N_DAYS] [-i N_INPUTS] [-j N_JUMPS] [-e N_EPOCHS] [-p {normalization,standardization,none}] 
[-o {adam,adagrad,adadelta,adamax,ftrl,nadam,optimizer,rmsprop,sgd}] [-l {mae,mape,mse,msle}]

Recurrent Neural Network:

  • -d : prediciton days. Default 5.
  • -i : number of days to use for prediction. Default 40.
  • -j : number of jumps in training data. Default 1.
  • -e : number of training epochs. Default 200.
  • -p : pre-processing data. Default normalization.
  • -o : optimization technique. Default adam.
  • -l : loss function. Default mae.

Due to the complexity of defining a model through command line, one can define it in: config_neural_network_models.txt

Recurrent_Neural_Network \
    = [ {'SimpleRNN': 
                {'units':100, 'activation':'linear', 'return_sequences':True} },
        {'SimpleRNN': 
                {'units':50, 'activation':'linear', 'return_sequences':True} },
        {'Dropout': 
                {'rate':0.2} },
        {'SimpleRNN': 
                {'units':21, 'activation':'linear', 'return_sequences':False} },
        {'Dense': 
                {'activation':'linear'} }]

rnn

lstm

usage: lstm [-d N_DAYS] [-i N_INPUTS] [-j N_JUMPS] [-e N_EPOCHS] [-p {normalization,standardization,none}] 
[-o {adam,adagrad,adadelta,adamax,ftrl,nadam,optimizer,rmsprop,sgd}] [-l {mae,mape,mse,msle}]

Long-Short Term Memory:

  • -d : prediciton days. Default 5.
  • -i : number of days to use for prediction. Default 40.
  • -j : number of jumps in training data. Default 1.
  • -e : number of training epochs. Default 200.
  • -p : pre-processing data. Default normalization.
  • -o : optimization technique. Default adam.
  • -l : loss function. Default mae.

Due to the complexity of defining a model through command line, one can define it in: config_neural_network_models.txt

Long_Short_Term_Memory \
    = [ {'LSTM': 
                {'units':25, 'activation':'tanh', 'return_sequences':True} },
        {'LSTM': 
                {'units':15, 'activation':'tanh', 'return_sequences':False} },
        {'Dense': 
                {'activation':'linear'} }]

lstm