[英]Why can't I import candlestick_ohlc from mplfinance
So I have been able to successfully install mplfinance with pip and when I import it alone I receive no error.所以我已经能够使用 pip 成功安装 mplfinance,当我单独导入它时,我没有收到任何错误。 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.虽然当我这样做时:
from mplfinance import candlestick_ohlc
我收到错误ImportError: cannot import name 'candlestick_ohlc' from 'mplfinance'
我再次检查了命令提示符,它说它已成功安装 mplfinance。 Why am I receiving this error?为什么我会收到此错误?
So from what I understand the Matplotlib for finance has changed so that:因此,据我了解,金融领域的 Matplotlib 发生了变化,因此:
To access the old API with the new mplfinance package installed, change statments要访问安装了新的 mplfinance package 的旧 API,请更改语句
from:从:
from mpl_finance import
to:至:
from mplfinance.original_flavor import candlestick_ohlc
and then it should work fine.然后它应该可以正常工作。
You do not have to import 'candlestick_ohlc' anymore.您不必再导入“candlestick_ohlc”。
'mplfinance.plot()' defaults to ohlc style charts. 'mplfinance.plot()' 默认为 ohlc 样式图表。
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://towardsdatascience.com/trading-toolbox-03-ohlc-charts-95b48bb9d748
https://openwritings.net/pg/mplfinance/python-draw-candlestickohlc-using-new-mplfinance https://openwritings.net/pg/mplfinance/python-draw-candlestickohlc-using-new-mplfinance
the first thing you have to do is install the library with the command:您要做的第一件事是使用以下命令安装库:
pip install mplfinance pip 安装 mplfinance
after that you can call the resource like:之后,您可以调用资源,例如:
from mplfinance.original_flavor import candlestick_ohlc从 mplfinance.original_flavor 导入烛台_ohlc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.