ta-lib 计算kdj
时间: 2023-08-13 22:05:47 浏览: 136
ta-lib库可以用来计算KDJ指标。在使用ta-lib计算KDJ指标时,可以使用STOCH函数。具体的参数配置如下:
```python
import talib
df\['talib_K'\], df\['talib_D'\] = talib.STOCH(df\['high'\].values, df\['low'\].values, df\['close'\].values, fastk_period=9, slowk_period=5, slowk_matype=1, slowd_period=5, slowd_matype=1)
df.loc\[:, 'talib_J'\] = 3.0 * df.loc\[:, 'talib_K'\] - 2.0 * df.loc\[:, 'talib_D'\]
```
这段代码会计算出KDJ指标的值,并将结果存储在DataFrame的相应列中。\[1\]
需要注意的是,ta-lib库中没有直接提供KDJ指标的计算方法,但可以使用STOCH函数来实现类似的效果。\[3\]
#### 引用[.reference_title]
- *1* *2* [国内股票KDJ指标计算,Python实现KDJ指标计算,Talib实现KDJ指标计算](https://blog.csdn.net/yifengdongying/article/details/120641725)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [VNPY 中基于Ta-lib的KDJ策略实现](https://blog.csdn.net/cuiyan6458/article/details/100347439)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文