最新版mplfinance画股市蜡烛图

记录下用python画蜡烛图

import tushare as ts import pandas as pd import matplotlib import matplotlib.pyplot as plt import mplfinance as mpf import numpy as np from datetime import datetimets.set_token('your token') pro = ts.pro_api() df = pro.daily(ts_code='000001.SZ', start_date='20180701', end_date='20180718') df['date'] = df['trade_date'].apply(lambda x: datetime.strptime(x, '%Y%m%d')) data = https://www.it610.com/article/df.loc[:,['date', 'open','close','high','low','vol']] data = https://www.it610.com/article/data.rename(columns={"vol": "volume"}) data.set_index('date', inplace=True) data.index.name = "Date" data.index = pd.DatetimeIndex(data.index) data=https://www.it610.com/article/data.reindex(index=data.index[::-1])# data.head mc = mpf.make_marketcolors(up='r',down='g') s= mpf.make_mpf_style(marketcolors=mc,mavcolors=['#4f8a8b','#fbd46d','#87556f'])mpf.plot(data,type='candle',volume=True, show_nontrading=True, figratio=(20,10), mav=(5,10,15),style=s)

最新版mplfinance画股市蜡烛图
文章图片

如何获取数据:
https://tushare.pro/register?reg=332190
画图:
https://github.com/matplotlib/mplfinance
【最新版mplfinance画股市蜡烛图】https://github.com/matplotlib/mplfinance/blob/master/examples/styles.ipynb

    推荐阅读