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!