fbpx

Simplest candlestick demo with Python Matplotlib

(Last Updated On: January 27, 2016)

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!

Subscribe For Latest Updates

Sign up to best of business news, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.

NOTE!

Check NEW site on stock forex and ETF analysis and automation

Scroll to Top