TAMomentum
TA.STOCHRSI() - RSI的随机指标
RSI的随机指标 (Stochastic RSI)
将随机指标应用于RSI值,比RSI更敏感的超买超卖指标。
语法
python
TA.STOCHRSI(data, timeperiod=14, fastk_period=5, fastd_period=3, fastd_matype=0)参数
| 参数名 | 类型 | 必选 | 默认值 | 说明 |
|---|---|---|---|---|
| data | any | 否 | - | 价格数据数组 |
| timeperiod | any | 否 | - | RSI计算周期,默认14 |
| fastk_period | any | 否 | - | FastK周期,默认5 |
| fastd_period | any | 否 | - | FastD周期,默认3 |
| fastd_matype | any | 否 | - | FastD移动平均类型 |
返回值
返回 (fastk, fastd) 元组,范围0-1(或0-100)。
信号解读
- StochRSI > 0.8: 极度超买
- StochRSI < 0.2: 极度超卖
- 金叉: FastK上穿FastD,买入
- 死叉: FastK下穿FastD,卖出
基础示例
python
def main():
while True:
records = exchange.GetRecords()
if len(records) < 50:
Sleep(1000)
continue
closes = [r['Close'] for r in records]
fastk, fastd = TA.STOCHRSI(closes, 14, 5, 3, 0)
Log(f"StochRSI K: {fastk[-1]:.3f}, D: {fastd[-1]:.3f}")
# 极度超买超卖
if fastk[-1] > 0.8 and fastd[-1] > 0.8:
Log("⚠️ 极度超买")
elif fastk[-1] < 0.2 and fastd[-1] < 0.2:
Log("💡 极度超卖")
# 金叉死叉
if fastk[-1] > fastd[-1] and fastk[-2] <= fastd[-2]:
if fastk[-1] < 0.5:
Log("✅ 低位金叉,买入")
Sleep(60000)优势
- 比RSI更早发出信号
- 对价格变化反应更快
- 适合短线交易