Machine Learning and Pattern Recognition for Stocks and Forex Part 3

Welcome to the Machine Learning for Forex and Stock analysis and algorithmic trading tutorial series. In this series, you will be taught how to apply machine learning and pattern recognition principles to the field of stocks and forex. In this video, we are briefly taking a closer look into the bid-ask spread before diving into pattern recognition.

This is especially useful for people interested in quantitative analysis and algo or high frequency trading. Even if you are not, the series will still be of great use to anyone interested in learning about machine learning and automatic pattern recognition, through a hands-on tutorial series.


  1. Eric Jurotich says:

    Any idea why the 0.0000 for my Spread doesnt start at the bottom of the
    graph? It starts at -0.0002 , so there is a white gap on the graph at the
    bottom before the Spread starts. Thanks

  2. drunkzenith says:

    Great tut (as all the others)! However, as soon as I add the ax1_2 lines,
    my dates on the x axis disappear. (they turn into 0.2 through 1.0 with .2
    Hope this screenshot explains what I see: 

  3. T1tan says:

    Hey Sentdex, I’m trying to replicate the above using iPython Notebook +
    pandas. Do you have any tips for that? Have you used pandas.Series or
    pandas.DataFrames to replicate any of your work?

  4. Rohan Pota says:

    Hey,I got the following error:
    Traceback (most recent call last):
    File ““, line 1, in
    File “”, line 23, in graphRawFX
    AttributeError: ‘Text’ object has no attribute ‘set_rotations’

    My code:

    import matplotlib
    import matplotlib.pyplot as plt
    import matplotlib.ticker as mticker
    import matplotlib.dates as mdates
    import numpy as np

    def graphRawFX():
    date,bid,ask= np.loadtxt(“GBPUSD1d.txt”,unpack = True,
    delimiter = “,”,


    fig = plt.figure(figsize=(10,7))

    ax1 = plt.subplot2grid((40,40),(0,0),rowspan=40, colspan = 40)

    ax1.xaxis.set_major_formatter(mdates.DateFormatter(“%Y-%m-%d %H:%M:%S”))
    for label in ax1.xaxis.get_ticklabels():



Comments are closed.