Quick look at our Data: Machine learning for Stocks and Forex Technical Analysis



Welcome to the Machine Learning for Forex and Stock analysis and algorithmic trading tutorial series. In this video, we are looking at and displaying the data that we are working with, and matplotlib. In this series, you will be taught how to apply machine learning and pattern recognition principles to the field of stocks and forex. This is especially useful for people interested in quantitative analysis and algo 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. Sentdex.com Facebook.com/sentdex Twitter.com/sentdex

Comments

  1. i am getting an error while running the program i am using phython 2.7.13. little help needed

    Traceback (most recent call last):
    File "<pyshell#2>", line 1, in <module>
    graphRawFX()
    NameError: name 'graphRawFX' is not defined
  2. I get the same error message as a couple of others NameError: name 'date' is not defined
  3. i tried this code exactly as is and the other examples, always same error: date is not defined.
  4. Hello there, want to let you know how much I greatly appreciate the tutorial. However, it keeps saying "name 'date' is not defined". Isnt this defined under the function name?
  5. I draw 2000 lines ,463 point per line , then it become really slow to zoom in and zoom, Do i need to change the plot tool, or change my computer?
  6. Hello. Thanks for your nice video!! I have a problem with the graph plotted. I don't know why there is a shift on the x-axis to the right. That means the starting date in my graph is not '2013-05-01' but '2013-04-30' instead. How can I fix it?? Thank you
  7. working codes for python 3.5

    import time
    import datetime
    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=',',
    converters={0:mdates.bytespdate2num('%Y%m%d%H%M%S')})
    # numpy passes a byte string to the converter instead of a string. In python 2, since bytes and str are equivalent it does not matter. For python 3, however, this results in an error as strpdate2num passes it to the standard library's strptime which only expects a string.
    fig = plt.figure(figsize=(10,7))
    ax1= plt.subplot2grid((40,40), (0,0), rowspan=40, colspan=40)
    ax1.plot(date,bid)
    ax1.plot(date,ask)

    ax1.xaxis.set_major_formatter(mdates.DataFormatter('%y-%m-%d %H:%M:%S'))

    plt.grid(True)
    plt.show()

    graphRawFx()
  8. I am using El Capitan:

    Could not open font file /Library/Fonts/NISC18030.ttf
    Could not open font file /System/Library/Fonts/Apple Color Emoji.ttf

    Graph isn't opening...
  9. Hello, I'm having a problem running the script on python and I tried everything to resolve it and still no progress. it keeps giving me the same error- Traceback (most recent call last):
    File "<pyshell#0>", line 1, in <module>
    graphRawFX()
    File "C:/Users/LoveCountyPawn/Desktop/Pip machine/Python algo trading/Data.py", line 15, in graphRawFX
    converters={0:mdates.strpdate2num('%Y%m%d%H%M%S')})
    File "C:\Python34\lib\site-packages\numpy\lib\npyio.py", line 805, in loadtxt
    fh = iter(open(fname))
    FileNotFoundError: [Errno 2] No such file or directory: 'C:/LoveCountyPawn/Desktop/Pip machine/Python algo trading/GBPUSD1D'
  10. The function doesn't run for me unless I call it. Is it supposed to run by itself? wtf?
  11. hey, i am from china.
    i just took a afternoon to install py2.7 with all file.
    i find a url include all file in google cloud drive :https://drive.google.com/folderview?id=0B83bAuUUiuy2TnVTV0JhdzBqcDg&usp=sharing
  12. please help,

    I keep getting

    Traceback (most recent call last):
    File "<pyshell#3>", line 1, in <module>
    graphRawFX()
    File "C:/Users/njaxcii/Desktop/algotrade/AlgoTradingTutorial.py", line 18, in graphRawFX
    ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'))
    AttributeError: 'list' object has no attribute 'xaxis'
  13. I got this error "NameError: name 'bid' is not defined". What is wrong?

    import matplotlib
    import matplotlib.pyplot as plt
    import matplotlib.ticker as mticker
    import matplotlib.dates as mdates
    import numpy as np
    import datetime
    date = datetime.date.today()

    def graphRawFX():
    date,bid,ask = np.loadtxt('GBPUSD1d.txt', unpack=True,
    delimiter=',',
    converters={0:mdates.strpdate2num('%Y%m%d%H%M%S')})

    fig = plt.figure(figsize=(10,7))
    ax1 = plt.subplot2grid((40,40), (0,0), rowspan=40, colspan=40)

    ax1.plot(date,bid)
    ax1.plot(date,ask)

    ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'))

    plt.grid(True)
    plt.show()
  14. I am not getting the graph part always .The problem is that, sometimes the graph is popped which is cool but sometimes the graph doesnt appear and pops the dailogue box as Runtime Error!!( MIcrosoft visual C++ Runtime library)
  15. I tried to run and I got a Name Error. Only difference between your environment and mine is that I'm using Python 2.7.9. Would that be in any effect to what we're doing here?
  16. i dont know what im doing wrong i keep on getting the following message (please not i am using python 3.5 n later versioins of matplotlib and numpy):
    Traceback (most recent call last):
    File "<pyshell#8>", line 1, in <module>
    graphRawFX()
    File "C:/Python Forex/python forex.py", line 9, in graphRawFX
    converters={0:mdates.strpdate2num('%Y%m%d%H%M%S')})
    File "C:\Users\Nick\AppData\Local\Programs\Python\Python35\lib\site-packages\numpy\lib\npyio.py", line 813, in loadtxt
    items = [conv(val) for (conv, val) in zip(converters, vals)]
    File "C:\Users\Nick\AppData\Local\Programs\Python\Python35\lib\site-packages\numpy\lib\npyio.py", line 813, in <listcomp>
    items = [conv(val) for (conv, val) in zip(converters, vals)]
    File "C:\Users\Nick\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\dates.py", line 305, in _call_
    return date2num(datetime.datetime(*time.strptime(s, self.fmt)[:6]))
    File "C:\Users\Nick\AppData\Local\Programs\Python\Python35\lib\_strptime.py", line 494, in _strptime_time
    tt = _strptime(data_string, format)[0]
    File "C:\Users\Nick\AppData\Local\Programs\Python\Python35\lib\_strptime.py", line 306, in _strptime
    raise TypeError(msg.format(index, type(arg)))
    TypeError: strptime() argument 0 must be str, not <class 'bytes'>

    anyone help?
  17. Last login: Sun Nov 1 20:58:23 on ttys000
    Jonel-Pericons-MacBook-Pro:~ jonelpericon$ cd desktop/Python_Lesson
    -bash: cd: desktop/Python_Lesson: No such file or directory
    Jonel-Pericons-MacBook-Pro:~ jonelpericon$ cd Desktop/Python_Lesson
    -bash: cd: Desktop/Python_Lesson: No such file or directory
    Jonel-Pericons-MacBook-Pro:~ jonelpericon$ cd Desktop\Python_Lesson
    -bash: cd: DesktopPython_Lesson: No such file or directory
    Jonel-Pericons-MacBook-Pro:~ jonelpericon$ cd Desktop
    Jonel-Pericons-MacBook-Pro:Desktop jonelpericon$ cd Python_Lessons
    Jonel-Pericons-MacBook-Pro:Python_Lessons jonelpericon$ python FirstLesson.py
    Traceback (most recent call last):
    File "FirstLesson.py", line 1, in <module>
    import matplotlib
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 1131, in <module>
    rcParams = rc_params()
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 975, in rc_params
    return rc_params_from_file(fname, fail_on_error)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 1100, in rc_params_from_file
    config_from_file = _rc_params_in_file(fname, fail_on_error)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 1018, in _rc_params_in_file
    with _open_file_or_url(fname) as fd:
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in _enter_
    return self.gen.next()
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 1000, in _open_file_or_url
    encoding = locale.getdefaultlocale()[1]
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 511, in getdefaultlocale
    return _parse_localename(localename)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 443, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
    ValueError: unknown locale: UTF-8
    Jonel-Pericons-MacBook-Pro:Python_Lessons jonelpericon$
  18. hey,can you tell me what idle you use,or say ,what the python editor use in this tutorial ^_^ I was searching a ligthweight idle or editor for python program,Thanks
  19. Why are you not including spread in graph analysis? is there a video you recommend that I check out to better explain spread?
  20. hI sENTDEX, i MADE IT TO CLASS 2 BUT I AM GUESSING: IS PYTHON GOOD TO INTERFACE WITH TRADESTATION? THAT'S THE NEXT PLATFORM I AM GOING TO LEARN TO USE. THANKS FOR YOUR TIME AND FOR SHARING


Additional Information:

Visibility: 32927

Duration: 11m 0s

Rating: 164