1

I need to plot a few candlesticks charts with additional lines and various graphics on the chart, but I found that matplotlib.finance has been deprecated. Replaced by mpl_finance, but that's unmaintained too.

What should a honest newborn python developer use these days to plot candlesticks? any ideas?

The code I would be going to use for this would be something like:

import matplotlib.pyplot as plt

from matplotlib.dates import DateFormatter, WeekdayLocator,\
    DayLocator, MONDAY
from matplotlib.finance import candlestick_ohlc

    mondays = WeekdayLocator(MONDAY)
    alldays = DayLocator()              # minor ticks on the days
    weekFormatter = DateFormatter('%b %d')  # e.g., Jan 12
    dayFormatter = DateFormatter('%d')      # e.g., 12

    fig, ax = plt.subplots()
    fig.subplots_adjust(bottom=0.2)
    ax.xaxis.set_major_locator(mondays)
    ax.xaxis.set_minor_locator(alldays)
    ax.xaxis.set_major_formatter(weekFormatter)
    # ax.xaxis.set_minor_formatter(dayFormatter)

    #plot_day_summary(ax, quotes, ticksize=3)
    candlestick_ohlc(ax, candles, width=0.6)

    ax.xaxis_date()
    ax.autoscale_view()
    plt.setp(plt.gca().get_xticklabels(),
             rotation=45, horizontalalignment='right')
Don Giulio
  • 2,946
  • 3
  • 43
  • 82

2 Answers2

0

You may use mpl_finance without restriction. It's available at github.com/matplotlib/mpl_finance. See here on how to install it.

"Un-maintained" simply means that if you find a bug in it, noone will fix it for you.

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
  • It means also that in case of breaking changes to the underlying platforms the risk of being stuck is very high. But ok, I guess I have no choice. thanks – Don Giulio Nov 04 '18 at 11:24
  • The code isn't very complicated. If it was to happen that an upstream package update breaks the code, you could always just copy the function from `mpl_finance` and fix it yourself. – ImportanceOfBeingErnest Nov 04 '18 at 11:51
  • @DonGiulio - it is now maintained, and there is a new version here: https://pypi.org/project/mplfinance/ – Daniel Goldfarb Jan 17 '20 at 20:36
0

@DonGiulio - it is now maintained, and there is a new version here: https://pypi.org/project/mplfinance/

Daniel Goldfarb
  • 6,937
  • 5
  • 29
  • 61