记录下用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 datetime
ts.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 = df.loc[:,['date', 'open','close','high','low','vol']]
data = data.rename(columns={"vol": "volume"})
data.set_index('date', inplace=True)
data.index.name = "Date"
data.index = pd.DatetimeIndex(data.index)
data=data.reindex(index=data.index[::-1])
# data.head
mc = mpf.make_marketcolors(up='r',down='g')
s = mpf.make_mpf_style(marketcolors&#