## ta-lib计算BOLL值、RSI值、OBV成交量

2015年6月25日 发表评论 阅读评论

### 一、BOLL布林线

```中轨线=N日的移动平均线

```(1) 股价高于这个波动区间，即突破阻力线，说明股价虚高，故卖出
(2) 股价低于这个波动区间，即跌破支撑线，说明股价虚低，故买入```

```import pandas as pd
import numpy as np
import talib as ta
import tushare as ts
dw = ts.get_k_data("600600")
dw = dw[-100:]
dw.index = range(len(dw))
dw['upper'], dw['middle'], dw['lower'] = ta.BBANDS(
dw.close.values,
timeperiod=20,
# number of non-biased standard deviations from the mean
nbdevup=2,
nbdevdn=2,
# Moving average type: simple moving average here
matype=0)```

### 二、RSI 强弱指数

RSI 计算方法如下：

```RSI＝[上升平均数÷(上升平均数＋下跌平均数)]×100

```当RSI高于70时，股票可以被视为超买，是卖出的时候。

```import pandas as pd
import numpy as np
import talib as ta
import tushare as ts
dw = ts.get_k_data("600600")
dw = dw[-100:]
close = dw.close.values
dw["rsi"] = ta.RSI(close, timeperiod=14)```

### 三、OBV 成交量

```当股价上升而OBV线下降，表示买盘无力，股价可能会回跌。

```import pandas as pd
import numpy as np
import talib as ta
import tushare as ts
dw = ts.get_k_data("600600")
dw = dw[-100:]
obvta = ta.OBV(dw['close'].values,dw['volume'].values)```

### 四、有关画图

You can donate through PayPal.
My paypal id: itybku@139.com
Paypal page: https://www.paypal.me/361way

1. 本文目前尚无任何评论.