'''
蜡烛图算法
parameter:以下参数均包含的有缺省值
security 聚宽格式股票代码,只支持['']单只股票格式
start_date 起始时间点
end_date 结束时间点
Note:
1.日本蜡烛图是最基础的数据整合形式,主要是包括了[开盘价/收盘价/日内最高/日内最低]
2.下面代码使用JoinQuant数据源做出蜡烛图算法的实现
3.图一蜡烛图,图二量比
4. .股票跌成狗,代码慌得一批~
.有问题可以留言,回不回复看大盘(心情)
author:aaron-clark-aic 20/07/2018
'''
def candlestick(security=standardStocks(['000915']),start_date=(datetime.date.today()-datetime.timedelta(days=120)),end_date=datetime.date.today()):
data = get_price(security,start_date=start_date,end_date=end_date,fields=['open','close','high','low','volume'])
_base_days = jqdata.get_trade_days(start_date=start_date, end_date=end_date)#基础交易日list
_open = np.hstack(data['open'].values)
_close = np.hstack(data['close'].values)
_high = np.hstack(data['high'].values)
_low = np.hstack(data['low'].values)
_volume = np.hstack(data['volume'].values)
fig = plt.figure(figsize=(17, 10))
ax_1 = fig.add_axes([0,0.2,1,0.5])
ax_2 = fig.add_axes([0,0,1,0.2])
mpf.candlestick2_ochl(ax = ax_1, opens = _open, closes = _close ,highs = _high, lows = _low ,width=0.5, colorup='r', colordown='g', alpha=0.81)
ax_1.set_xticks(range(0, len(_base_days), 1))
ax_1.grid(False)
mpf.volume_overlay(ax = ax_2,opens = _open, closes = _close, volumes = _volume, colorup='r', colordown='g', width=0.5, alpha=0.81)
ax_2.set_xticks(range(0, len(_base_days), 1))
ax_2.set_xticklabels(_base_days, rotation=90)
ax_2.grid(True)
plt.show()