# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: proj_env
#     language: python
#     name: proj_env
# ---

from fastquant import get_stock_data, backtest
from gaussian_hmm import *
import matplotlib.pyplot as plt

# +
params = {
    'n_components': 2, 
    'algorithm': 'map', 
    'n_iter': 100, 
    'd': 5,
    'name':'GHMM'
}

ghmm = GHMM(params=params)
# -

# back testing dates on AAPL 2019-01-01 to 2020-05-31
back_test_data = get_stock_data('AAPL', '2019-01-01', '2020-05-31')

# training data AAPL 2017-08-01 to 2019-01-01
training_data = get_stock_data('AAPL', '2017-08-01', '2019-01-01')

ghmm.train(train_data=training_data)

preds,actual = ghmm.predict(test_data=back_test_data)



StarcoderdataJupyterScriptsDedupFiltered