Code Monkey home page Code Monkey logo

mpl-finance's Introduction

Build Status

This package is deprecated. Please go here for the new version: https://github.com/matplotlib/mplfinance


To Install:






Background

My name is Daniel Goldfarb. In November 2019, I became the maintainer of matplotlib/mpl-finance, and immediately began work on a new version of the module, with an all new API. The old API is still available in the new package, and will likely remain so for several months, at least until we are confident that the new API provides all of the old API's functionality (and more). This package is now deprecated. Please follow the above links to the new module. (This deprecated package consisted of code extracted from the deprecated matplotlib.finance module along with a few examples of usage. The code was un-maintained for over three years.)

Purpose

It's good to have a single statement of purpose, to guide development. The original documention for the (now twice deprecated) matplotlib.finance says that it was a set of functions "for collecting, analyzing and plotting financial data." --- I disagree with the "for collecting" part:    mplfinance is part of matplotlib.   Therefore, I would say the primary purpose of mplfinance is the visualization of financial data. However, since analyzing financial data often involves visualization (for example moving averages, oscillators, bollinger bands, etc.) let's say this also includes analyzing financial data (at least to the extent that such analysis involves visualization). Putting this into a single statement to guide development going forward:


The mplfinance package provides utilities for the visualization, and visual analysis, of financial data


Let's leave the collection and acquistion of financial data to other packages. We will focus on visualization, and visual analysis, while other packages can focus on various ways of acquiring the data. That said, we can certainly provide APIs for interfacing with packages that acquire financial data, in order to more easily and directly visualize and analyze that data.

For more information, please see the following links:

mpl-finance's People

Contributors

akkana avatar anntzer avatar chanseathink avatar danielgoldfarb avatar facorazza avatar jenshnielsen avatar john-colvin avatar tacaswell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mpl-finance's Issues

Error calling candlestick_ohlc

Hi,

My data has the following structure:

df.head()
Out[90]: 
                Time     Open     High      Low    Close
33750  736859.197917  1.18242  1.18245  1.18218  1.18221
33751  736859.201389  1.18221  1.18252  1.18199  1.18232
33752  736859.204861  1.18232  1.18275  1.18232  1.18253
33753  736859.208333  1.18254  1.18256  1.18172  1.18172
33754  736859.211806  1.18173  1.18211  1.18159  1.18187

But when I call:

fig, ax = plt.subplots()
candlestick_ohlc(ax, df.values)

I get the following error:

ValueError: not enough values to unpack (expected 5, got 4)

What's the problem?

Regards,
Mark

volume_overlay function display error color

When the open and close are same price, the color is the down color, but it should be the up color.
Current code:
colors = [colord[open < close]
for open, close in zip(opens, closes)
if open != -1 and close != -1]
I think the compare between open and close should be close >= open, see below:
colors = [colord[close >= open]
for open, close in zip(opens, closes)
if open != -1 and close != -1]

adding time functionality

i know this is not maintained but how big of a deal would it be to add time functionality to the existing bar and candle functions to handle intra-day plotting (or create new functions based on the existing ones)? I am happy to help where I can, more of a user than coder... the source code is a little beyond my ability. Thanks. Bill

Wrong default width for candlestick2_ohlc( ) function and something else.

Issue 1
Hello, I'm new to github and python. But I just read the source code of mpl_finance.py, and found that in the function
def candlestick2_ohlc(ax, opens, highs, lows, closes, width=4, colorup='k', colordown='r', alpha=0.75, ):
the width should probably be 0.4, right? Otherwise the bars will be overlapped.

Issue 2
Also inside this function definition,
rangeCollection = LineCollection(rangeSegments, colors=((0, 0, 0, 1), ), linewidths=lw, antialiaseds=useAA, )
This is the plot of the vertical lines of the candlesticks. But I think the colors shouldn't be black, instead setting colors = colors would be more sensible, right?

Issue 3

In the other 3 functions similar to this, which are
def candlestick2_ochl(ax, opens, closes, highs, lows, width=4, colorup='k', colordown='r', alpha=0.75, ):

def plot_day_summary2_ochl(ax, opens, closes, highs, lows, ticksize=4, colorup='k', colordown='r', ):
and
def plot_day_summary2_ohlc(ax, opens, highs, lows, closes, ticksize=4, colorup='k', colordown='r', ):
shouldn't the width and ticksize parameters all be set to 0.4 in the same way? Another question is why colorup defaults to black color, it seems wierd to me. In China, we typically use color red for up, green/blue for down. And I remember that in US, typically the convention is color green for up, red for down. Thus, black color for moving up is strange to me.

I don't know how to use Pull request yet. But I will try.

candlestick2_ohlc plotting alignment problem

While using candlestick2_ohlc plotting, the starting point and the ending point are not located at the origin, left some space.

Is there any way to set the start at the origin?

2010_2011_k-plot

use tulipy and accept an array of technical indicators as an argument (feature request)

Hi Daniel, thank you for taking over the maintainance of mpl-finance. I agree with you about the new mission statement. Here is a feature request for you to consider. (Hope it's ok to post it as an issue.) The tulipy project already implemented lots of technical indicators. It would be nice to be able to use them in mpl_finance. Here is a short piece showing how I would like to be able to pass my chosen technical indicators as arguments to candlestick_ohlc():

#!/usr/bin/python3

import numpy as np
import tulipy as ti
from datetime import datetime

def candlestick_ohlc(quotes, ti_array):
    close_prices = quotes['Close'].copy(order='C')
    for ti in ti_array:
        f = ti['f']
        del ti['f']
        print(f.full_name, f(close_prices, **ti))
        # of course in real code it should be plotting here.

dt = [float] * 6
dt[0] = 'datetime64[D]'
convertfunc = lambda x: datetime.strptime(x.decode('utf8'), '%m/%d/%Y')
daily = np.genfromtxt('SP500_NOV2019_Hist.csv',
    delimiter=',', autostrip=True, names=True, dtype=dt,
    converters = {'Date': convertfunc}
)
candlestick_ohlc(daily, [
    {'f':ti.sma, 'period':5},
    {'f':ti.sma, 'period':10},
    {'f':ti.macd, 'short_period':2, 'long_period':5, 'signal_period':9}
] )

What is different from matplotlib.finance ?

The official guide mentions the old finance module is deprecated and has been moved to mpl_finance.
Is anything actually different, or is there a good reasons for adding this additional library, since it doesn't come with matplotlib ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.