Matplotlib Tutorial 14 - candlestick OHLC graphs

preview_player
Показать описание
In this Matplotlib tutorial, we're going to cover how to create open, high, low, close (OHLC) candlestick charts within Matplotlib. These graphs are used to display time-series stock price information in a condensed form.

Рекомендации по теме
Комментарии
Автор

for people coming here in 2021+
matplotlib doesn't include the finance module normally:
but you can
pip install --upgrade mplfinance
then
from mplfinance.original_flavor import candlestick_ohlc

also all the ohlc data can be formatted in 1 line using:
ohlc = list(zip(date, openp, highp, lowp, closep, volume))

OriAlon
Автор

You're videos are unbelieveble! I think there have been some downs in people who watch them because of the video where you introduce us to internet data... sorry about that. But I can't stop watching these <3

tomasenrique
Автор

I love coding with you via the videos. Some modules or code you put there may be deprecated but I was able to google StackOverflow to fix the code or install the updated modules. It is a learning curve and I learned a lot from you.

TXfoxie
Автор

Can you please a make a tutorial regarding drawing data from interactive brokers API and creating live candlestick chart

kartiksaini
Автор

Why not use a zip for creating ohlc? If you need a list instead of a generator, just wrap the whole thing in list() when you're making it.

ohlc = zip(date, openp, highp, lowp, closep, volume)

まさしん-oe
Автор

wouldn't hurt to use "for x, y in enumerate(date)" or at least "for x in range(len(date))" instead of an ugly while loop for the ohlc data. i guess you did that for not to overcomplicate things for beginners, but i think being confronted with pythonic stuff like this will benefit them greatly. for more advanced python programmers, that kind of while loop is just irritating ;)
anyway, thanks for this relatively quick overview of matplotlib. regarding the styling of labels and such, i learned a few things that i didn't know about from just browsing the wiki.

F
Автор

How could i add other stuff to the same plot? Like horizontal/vertical lines at arbitrary positions? it seems i cannot simply do plt.plot(date) after the candlestick_ohlc fucntion is called. thanks!

messibarca
Автор

some might get an import error among other issues if you're using a different version of matplotlib or python. I had to make the following changes...

remove the "_ohlc":

from matplotlib.finance import candlestick

change the order of the ohlc data:

while x < y:
append_me = date[x], openp[x], closep[x], highp[x], lowp[x]

rth-sg
Автор

Thank you Sentdex for your tutorials.I was trying to use a candlestick chart but for some reason the candlesticks are all green. I assume that closep<openp, then the candlesticks should be red. Any reason why?Or my assumption is wrong?

kaleabwoldemariam
Автор

could you tell me how to draw a line that shows the maximum value and minimum ?

linazahim
Автор

How to plot volume to each candle. Volume ask right and volume bid left

fast
Автор

The series since he started giving finance link is not working. you can't follow things not workable.

emcemimotionandcontrol
Автор

hey how can i connect to my local database to get data from and to plot candlestick graph

benseshi
Автор

Why isn't the ohlc graph complete. As in whats the reason for the gaps between candlesticks. Is there a way to fill the gaps.

mindOVERmatter
Автор

How would you get rid of the weekend gaps while still keeping dates as x-ticks? So far the only thing I can come up with is make each week its own subplot, which seems inefficient.

shakopython
Автор

does anyone know how to do it with quandl dataframe, i mean getting a quandl dataframe and then plotting a candlestick graph from it.

kenrosenberg
Автор

I am having this warning message and my graph isnt showing up.

MatplotlibDeprecationWarning: The finance module has been deprecated in mpl 2.0 and will be removed in mpl 2.2. Please use the module mpl_finance instead.
warnings.warn(message, mplDeprecation, stacklevel=1)


Love your tutorial but this yahoo finance api being shutdown or whatever kinda ruins the fun.

saadahmed
Автор

It may be worth noting that since it is deprecated, you'll need to install mpl_finance with Anaconda Python terminal, not regular windows CMD. It wouldn't work for me with just the windows edition, had to do it in Anaconda.

slambodianjones
Автор

What is the required format for times rather than dates?

david
Автор

Matplotlib.finance has been depreciated for some time. I installed mpl_finance but I can't seem to use the module. Is it possible for you to do a video about installing and using mpl_finance?

lizzybennet