212f6fedad
- data/service.py: 数据拉取服务,从 TimescaleDB 读取 K 线/Ticker 等行情数据 - indicators/momentum.py: 动量类指标(RSI/MACD/Stochastic 等) - indicators/trend.py: 趋势类指标(EMA/SMA/ADX/SuperTrend 等) - indicators/volatility.py: 波动率指标(Bollinger/ATR/Keltner 等) - indicators/volume.py: 成交量指标(OBV/VWAP/MFI 等)
31 lines
919 B
Python
31 lines
919 B
Python
"""
|
|
技术指标库
|
|
|
|
提供常用的趋势、动量、波动率和成交量指标计算。
|
|
所有函数均为纯 Python 实现,无外部依赖。
|
|
|
|
用法:
|
|
from engine.indicators import sma, ema, macd, rsi, bollinger, atr
|
|
|
|
closes = [100.0, 101.0, 102.0, ...]
|
|
ma = sma(closes, period=20)
|
|
rsi_vals = rsi(closes, period=14)
|
|
upper, mid, lower = bollinger(closes, period=20, std=2)
|
|
"""
|
|
|
|
from .trend import sma, ema, macd, macd_signal, macd_histogram, adx
|
|
from .momentum import rsi, stoch, stoch_k, stoch_d
|
|
from .volatility import bollinger, bollinger_upper, bollinger_mid, bollinger_lower, atr
|
|
from .volume import obv, vwap
|
|
|
|
__all__ = [
|
|
# 趋势
|
|
"sma", "ema", "macd", "macd_signal", "macd_histogram", "adx",
|
|
# 动量
|
|
"rsi", "stoch", "stoch_k", "stoch_d",
|
|
# 波动率
|
|
"bollinger", "bollinger_upper", "bollinger_mid", "bollinger_lower", "atr",
|
|
# 成交量
|
|
"obv", "vwap",
|
|
]
|