So I have been able to successfully install mplfinance with pip and when I import it alone I receive no error. Though when I do: from mplfinance import candlestick_ohlc I get the error ImportError: cannot import name 'candlestick_ohlc' from 'mplfinance' I have checked command prompt again, and it says it has successfully installed mplfinance. Why am I receiving this error?
            Asked
            
        
        
            Active
            
        
            Viewed 2.7k times
        
    14
            
            
        
        Trenton McKinney
        
- 56,955
 - 33
 - 144
 - 158
 
        benito.cano
        
- 797
 - 1
 - 8
 - 23
 
- 
                    1Can you just `import mplfinance`? – mkrieger1 Apr 15 '20 at 20:39
 - 
                    6`from mplfinance.original_flavor import candlestick_ohlc`? See https://pypi.org/project/mplfinance/ – BigBen Apr 15 '20 at 20:40
 - 
                    @mkrieger1, I can import mplfinance without an issue, though when I try to get candlestick_ohlc is when I get the error. – benito.cano Apr 15 '20 at 20:43
 - 
                    @BigBen, I get the same error – benito.cano Apr 15 '20 at 20:44
 - 
                    1Is there a particular reason you are importing candlestick? mpf.plot(x, type='candle') will do the trick for you. – Brijesh Apr 18 '20 at 00:00
 - 
                    So I found out the reason was because mplfinance has changed the library, so now to use old pacakges, you have to do "from mplfinance.original_flavor import candlestick_ohlc" – benito.cano Apr 18 '20 at 16:33
 
3 Answers
33
            So from what I understand the Matplotlib for finance has changed so that:
To access the old API with the new mplfinance package installed, change statments
from:
from mpl_finance import 
to:
    from mplfinance.original_flavor import candlestick_ohlc
and then it should work fine.
        benito.cano
        
- 797
 - 1
 - 8
 - 23
 
13
            
            
        You do not have to import 'candlestick_ohlc' anymore.
'mplfinance.plot()' defaults to ohlc style charts.
These links provide good examples. The second one uses candlesticks. You can change that arg.
https://towardsdatascience.com/trading-toolbox-03-ohlc-charts-95b48bb9d748
https://openwritings.net/pg/mplfinance/python-draw-candlestickohlc-using-new-mplfinance
        Nicholas Portalupi
        
- 131
 - 3
 
-1
            
            
        the first thing you have to do is install the library with the command:
pip install mplfinance
after that you can call the resource like:
from mplfinance.original_flavor import candlestick_ohlc