Tag Archives: matplotlib

Python Seaborn charting package over Matplotlib for finance time series

Python Seaborn charting package over Matplotlib for finance time series

Seaborn is very use as a Python package over Matplotlib. Matplotlib is the original popular charting package but the other is much more impressive. If you look at the Gihub.io link, there are better examples on how to manipulate string dates to datetime64 which is needed for Matplotlib. Watch this to help you out to improve your visualization.

 

Here is the Facebook group these live webinars are in

https://www.facebook.com/groups/quantlabsnet/?ref=bookmarks

Helpful links from video:

https://seaborn.pydata.org/examples/heatmap_annotation.html

https://stackoverflow.com/questions/22795348/plotting-time-series-data-with-seaborn

http://financeandpython.com/SeabornDataVisualization/6/2.html

https://jakevdp.github.io/PythonDataScienceHandbook/03.11-working-with-time-series.html

https://stackoverflow.com/questions/37790429/seaborn-heatmap-using-pandas-dataframe

 

Update: Which Bitcoin crypto currency bot project? Gekko vs ccxt vs Tribeca vs Blackbird

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Live chart Matplotlib with GUI libraries Tkinter PyQt

Live chart Matplotlib with GUI libraries Tkinter PyQt

A couple of things.  I would revist after 1.5 years

See below for my opinion on these Python GUI libraries

Potential commercial options with Plotly

https://plot.ly/python/candlestick-charts/

Live MatplotLib

https://stackoverflow.com/questions/11874767/real-time-plotting-in-while-loop-with-matplotlib

https://pythonprogramming.net/plotting-live-bitcoin-price-data-tkinter-matplotlib/

Setdex puts out the best videos for this

More general GUI

 

Decent charting Python tool with ptQt (read Youtube video comments)

http://zetcode.com/gui/pyqt4/

ttp://www.youtube.com/playlist?list=PLQVvvaa0QuDcR-u9O8LyLR7URiKuW-XZq

PyQt4 vs 5 sounds still pretty complicated since my experience. Also licensing is too restricted.

http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html

https://stackoverflow.com/questions/37048313/pyqt5-or-pyqt4-should-i-do-the-upgrade

https://stackoverflow.com/questions/30950827/uninstalling-pyqt5-to-install-pyqt4

 

Most open GUI library with fewest license restrictions

https://wiki.python.org/moin/TkInter

https://amp.reddit.com/r/learnpython/comments/3pif4k/tkinter_vs_pyqt_vs_wxpython/

Great example of Tkinter with algo trading in mind

Live chart https://stackoverflow.com/questions/11270078/how-do-i-refresh-a-matplotlib-plot-in-a-tkinter-window

https://stackoverflow.com/questions/30774281/update-matplotlib-plot-in-tkinter-gui

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Intro to Scientific Python with Math Behind It – Matplotlib

Intro to Scientific Python with  Math Behind It – Matplotlib

This always has been a good site as it fast growing

http://www.kdnuggets.com/2016/06/intro-scientific-python-matplotlib.html

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Matlab 2016a calls Python Matplotlib animation demo

Matlab 2016a calls Python Matplotlib animation demo

A simple demo of showcasing this

http://cs231n.github.io/python-numpy-tutorial/

http://www.mathworks.com/help/matlab/getting-started_buik_wp-3.html

http://www.mathworks.com/help/matlab/matlab_external/call-user-defined-custom-module.html

Join my FREE newsletter to see what other Matlab/Python ideas I will implement into automated trading

 

 

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Simplest 2 candlesticks demo with Python Matplotlib

Simplest 2 candlesticks demo with Python Matplotlib

This is from the book Python in Finance p107

Join my FREE newsletter to learn more about other simple charting in Python for automated trading

 Source code:

# -*- coding: utf-8 -*-
“””
Created on Tue Jan 26 19:28:55 2016

@author: quantlabsnet
“””
#Python in Finance p107

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.finance as mpf

start = (2014, 5, 1)
end = (2014, 6, 30)
quotes = mpf.quotes_historical_yahoo_ohlc(‘YHOO’, start, end)
#quotes = mpf.quotes_historical_yahoo(‘^GDAXI’, start, end)
#quotes[:2]

quotes2 = mpf.quotes_historical_yahoo_ohlc(‘GM’, start, end)

fig, ax = plt.subplots(figsize=(8, 5))
fig.subplots_adjust(bottom=0.2)

print “Hello”
#use Line2d
#mpf.plot_day_summary_oclh(ax, quotes, ticksize=3, colorup=’k’, colordown=’r’)#
mpf.candlestick_ohlc(ax, quotes, width=0.6, colorup=’b’, colordown=’r’)
mpf.candlestick_ohlc(ax, quotes2, width=0.6, colorup=’g’, colordown=’k’)
#mpf.candlestick(ax, quotes, width=0.6, colorup=’b’, colordown=’r’)
plt.grid(True)
ax.xaxis_date()
# dates on the x-axis
ax.autoscale_view()

plt.setp(plt.gca().get_xticklabels(), rotation=30)
#raw_input(“Press Enter to continue…”)
print “bye”

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Simplest candlestick demo with Python Matplotlib

Simplest candlestick demo with Python Matplotlib

This is from the book Python in Finance p107

Join my FREE newsletter to learn more about other simple charting in Python for automated trading

Source code:

# -*- coding: utf-8 -*-
“””
Created on Tue Jan 26 19:28:55 2016

@author: quantlabsnet
“””
#Python in Finance p107

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.finance as mpf

start = (2014, 5, 1)
end = (2014, 6, 30)
quotes = mpf.quotes_historical_yahoo_ohlc(‘^GDAXI’, start, end)
#quotes = mpf.quotes_historical_yahoo(‘^GDAXI’, start, end)
quotes[:2]

fig, ax = plt.subplots(figsize=(8, 5))
fig.subplots_adjust(bottom=0.2)

print “Hello”
#use Line2d
#mpf.plot_day_summary_oclh(ax, quotes, ticksize=3, colorup=’k’, colordown=’r’)#
mpf.candlestick_ohlc(ax, quotes, width=0.6, colorup=’b’, colordown=’r’)
#mpf.candlestick(ax, quotes, width=0.6, colorup=’b’, colordown=’r’)
plt.grid(True)
ax.xaxis_date()
# dates on the x-axis
ax.autoscale_view()

plt.setp(plt.gca().get_xticklabels(), rotation=30)
#raw_input(“Press Enter to continue…”)
print “bye”

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Python Matplotlib MACD demo

Python Matplotlib MACD demo

Note that I get a strange error of:

ImportError: cannot import name candlestick

This is from:

from matplotlib.finance import candlestick

 

https://pythonprogramming.net/advanced-matplotlib-graphing-charting-tutorial/

Solution from just candlestick only, I used: http://stackoverflow.com/questions/34482714/importerror-in-candlestick-example-from-matplotlib-documentation-cannot-import

NOTE: This can sometimes be a mess so I am going to switch over to PyQtGraph

Join my FREE newsletter to learn more about charting with Python

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Best option for time series with Python matplotlib

Best option for time series with Python matplotlib

There are 3 coding samples below which demo auto scaling for dates in Python’s MatPlotLib. Best one appears to be the last one.

Sourced links are listed as well

Join my FREE newsletter to learn how I use these coding samples for automated trading in Python

#http://stackoverflow.com/questions/29461608/matplotlib-fixing-x-axis-scale-and-autoscale-y-axis

# import numpy as np
# import matplotlib.pyplot as plt
#
# x, y = np.arange(0,101,1) ,300 - 0.1*np.arange(0,101,1)
# mask = (x >= 50) & (x <= 100)
#
# fig, ax = plt.subplots()
# ax.scatter(x[mask], y[mask])
#
# plt.show()

#http://stackoverflow.com/questions/32972371/how-to-show-date-and-time-on-x-axis-in-matplotlib
# import matplotlib.pyplot as plt
# import pandas as pd
# import matplotlib.dates as mdates
#
# times = pd.date_range('2015-10-06', periods=500, freq='10min')
#
# fig, ax = plt.subplots(1)
# fig.autofmt_xdate()
# plt.plot(times, range(times.size))
#
# xfmt = mdates.DateFormatter('%d-%m-%y %H:%M')
# ax.xaxis.set_major_formatter(xfmt)
#
# plt.show()

#this one works best and easiest it seems
#http://blog.mafr.de/2012/03/11/time-series-data-with-matplotlib/
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates

days, impressions = np.loadtxt("page-impressions.csv", unpack=True,
        converters={ 0: mdates.strpdate2num('%Y-%m-%d')})

plt.plot_date(x=days, y=impressions, fmt="r-")
plt.title("Pageessions on example.com")
plt.ylabel("Page impressions")
plt.grid(True)
plt.show()
NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Demo of Python Data Science with live Matplotlib chart

Demo of Python Data Science with live Matplotlib chart

My first real Python script with live charts

See how my built my environment on my Mac at

Instruction to get Python Data Science working on Mac

Join my FREE newsletter to learn how I could use Python for automated trading

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Fastest way to install Python with SciPy Numpy Pandas Matplotlib in Ubuntu Linux

Fastest way to install Python with SciPy Numpy Pandas Matplotlib in Ubuntu Linux

Honestly all the other online tutorials I used were junk so I decided to create my own to help anyone out there using Ubuntu Linux.
All chosen tools were open source and free!

SUCCESS AS THIS WAS THE EASIEST PATH TO INSTALL. IT WAS ALSO THE FARTHEST I GOT WITH PYCHARM and IPYTHON QTCONSOLE!

My helpful links from the video:

http://askubuntu.com/questions/101591/how-do-i-install-python-2-7-2-on-ubuntu

http://askubuntu.com/questions/70883/how-do-i-install-python-pandas

http://www.scipy.org/install.html

Choosing the Best Python IDE

How To Install PyCharm 3.1 On Ubuntu, Linux Mint And Elementary OS

http://www.ubuntu.com/download/desktop

How To Paste Code in Python Interpreter? Hint: Use iPython

https://ipython.org/ipython-doc/3/interactive/qtconsole.html

http://stackoverflow.com/questions/7712389/copy-paste-into-python-interactive-interpreter-and-indentation

https://www.jetbrains.com/webstorm/help/system-requirements-and-installation.html#d208145e225

https://ipython.org/ipython-doc/3/install/install.html

http://matplotlib.org/examples/lines_bars_and_markers/fill_demo.html

http://matplotlib.org/examples/pylab_examples/demo_ribbon_box.html

Choosing the Best Python IDE

Join my FREE newsletter to learn more about how I may use this Python experiment for my automated trading 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!