Boll指标研究 -- 知识铺
<span><span>def</span> <span>get_boll</span><span>(security, start_date=None, end_date=None, time_count=<span>10</span>)</span>:</span> hs_data=get_price(security,start_date=start_date,end_date=end_date,frequency=<span>'daily'</span>,fields=<span>None</span>,skip_paused=<span>False</span>,fq=<span>'pre'</span>) stock_data = get_price(securirty, end_date= end_date, frequency= <span>'daily'</span>, fields= <span>'close'</span>, skip_paused= <span>True</span>, fq= <span>'pre'</span>, count= (len(hs_data[<span>'close'</span>])+time_count<span>-1</span>)) upper, middle, lower = talib.BBANDS(stock_data[<span>'close'</span>].values, timeperiod=time_count,nbdevup=<span>2</span>,nbdevdn=<span>2</span>,matype=<span>0</span>) stock_data = pd.DataFrame({<span>'upper'</span>: upper, <span>'middle'</span>: middle, <span>'lower'</span>: lower}, index= stock_data.index) stock_data = stock_data.dropna() stock_data[<span>'close'</span>] = hs_data[<span>'close'</span>] <span>return</span> stock_data <span><span>def</span> <span>show_boll</span><span>(stock_data)</span>:</span> plt.figure(figsize=(<span>20</span>, <span>5</span>)) plt.grid() plt.plot(stock_data[<span>'upper'</span>], <span>'-'</span>, color=<span>'r'</span>) plt.plot(stock_data[<span>'lower'</span>], <span>'-'</span>, color=<span>'r'</span>) plt.plot(stock_data[<span>'middle'</span>], <span>'-.'</span>, color=<span>'b'</span>) plt.show() Boll指标研究 布林线指标,即BOLL指标,其英文全称是“Bollinger Bands”,布林线(BOLL)由约翰·布林先生创造,其利用统计原理,一般而言,股价……