13.08.2022 Views

advanced-algorithmic-trading

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

480

Figure 31.3: Trend Following Regime Detection with HMM

from hmmlearn.hmm import GaussianHMM

from matplotlib import cm, pyplot as plt

from matplotlib.dates import YearLocator, MonthLocator

import numpy as np

import pandas as pd

import seaborn as sns

def obtain_prices_df(csv_filepath, end_date):

"""

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!