TAMomentum
TA.STOCHF() - 快速随机指标
快速随机指标 (Fast Stochastic Oscillator)
比标准随机指标更敏感,不经过平滑处理,适合短线交易。
语法
python
TA.STOCHF(high, low, close, fastk_period=5, fastd_period=3, fastd_matype=0)参数
| 参数名 | 类型 | 必选 | 默认值 | 说明 |
|---|---|---|---|---|
| high | any | 否 | - | 最高价数组 |
| low | any | 否 | - | 最低价数组 |
| close | any | 否 | - | 收盘价数组 |
| fastk_period | any | 否 | - | FastK 周期,默认 5 |
| fastd_period | any | 否 | - | FastD 周期,默认 3 |
| fastd_matype | any | 否 | - | FastD 移动平均类型,默认 0 (SMA) |
返回值
返回 (fastk, fastd) 元组,范围 0-100。
信号解读
- FastK > 80: 超买区域
- FastK < 20: 超卖区域
- FastK 上穿 FastD: 金叉,买入信号
- FastK 下穿 FastD: 死叉,卖出信号
基础示例
python
def main():
while True:
records = exchange.GetRecords()
if len(records) < 30:
Sleep(1000)
continue
highs = [r['High'] for r in records]
lows = [r['Low'] for r in records]
closes = [r['Close'] for r in records]
fastk, fastd = TA.STOCHF(highs, lows, closes, 5, 3, 0)
Log(f"FastK: {fastk[-1]:.2f}, FastD: {fastd[-1]:.2f}")
# 金叉死叉
if fastk[-1] > fastd[-1] and fastk[-2] <= fastd[-2]:
if fastk[-1] < 20:
Log("✅ 超卖区金叉,强烈买入")
elif fastk[-1] < fastd[-1] and fastk[-2] >= fastd[-2]:
if fastk[-1] > 80:
Log("❌ 超买区死叉,强烈卖出")
Sleep(60000)与STOCH对比
| 指标 | 灵敏度 | 假信号 | 适用 |
|---|---|---|---|
| STOCHF | 高 | 多 | 短线 |
| STOCH | 中 | 少 | 波段 |