Compute technical indicators and generate trading signals for Chinese commodity futures, financial index futures, crude oil, and shipping index markets.
Use this skill when:
china-commodity-quotes to get price data for the target contractThrough china-commodity-quotes, you can get:
open, high, low, close (daily or intraday)volume and open_interestFor multi-day historical data (best for indicators):
text
https://stock2.finance.sina.com.cn/futures/api/jsonp.php/var%20_=new%20Date().getTime()/InnerFuturesNewService.getDailyKLine?symbol=<CONTRACT_CODE>&datalen=<DAYS>
Example (curl):
bash
curl -s "https://stock2.finance.sina.com.cn/futures/api/jsonp.php/InnerFuturesNewService.getDailyKLine?symbol=IF0&datalen=60"
For minute-level data:
text
https://stock2.finance.sina.com.cn/futures/api/jsonp.php/InnerFuturesNewService.getMinLine?symbol=<CONTRACT_CODE>&type=<M1|M5|M15|M30|M60>
Simple Moving Average (SMA):
text
SMA(n) = (C1 + C2 + ... + Cn) / n
Where C = closing price, n = period
Common periods for Chinese futures:
Golden Cross (金叉) — Buy Signal: Short-term MA crosses ABOVE long-term MA (e.g., MA5 上穿 MA20)
Death Cross (死叉) — Sell Signal: Short-term MA crosses BELOW long-term MA (e.g., MA5 下穿 MA20)
Step-by-step calculation:
text
Step 1: EMA12 = EMA(C, 12) — Fast EMA
Step 2: EMA26 = EMA(C, 26) — Slow EMA
Step 3: DIF = EMA12 - EMA26 — Difference
Step 4: DEA = EMA(DIF, 9) — Signal line (9-day EMA of DIF)
Step 5: MACD bar = 2 × (DIF - DEA) — Histogram
EMA calculation (recursive):
text
EMA(today) = (C × K) + (EMA(yesterday) × (1 - K))
Where K = 2 / (N + 1)
Signals:
SignalConditionInterpretationGolden crossDIF crosses above DEABullish 🟢Death crossDIF crosses below DEABearish 🔴Zero crossing (up)DIF crosses above 0Trend turning bullishZero crossing (down)DIF crosses below 0Trend turning bearishDivergence (bullish)Price lower low, MACD higher lowReversal up ⬆️Divergence (bearish)Price higher high, MACD lower highReversal down ⬇️
text
RSI(n) = 100 - [100 / (1 + RS)]
RS = AvgGain(n) / AvgLoss(n)
Where:
AvgGain(n) = average of up-moves over n periodsAvgLoss(n) = average of down-moves over n periodsInterpretation:
RSI RangeSignal> 80Overbought (超买) — potential sell ⚠️70 - 80Strongly bullish, nearing overbought30 - 70Normal range20 - 30Strongly bearish, nearing oversold< 20Oversold (超卖) — potential buy ⚠️
text
Middle Band = SMA(n)
Upper Band = Middle Band + (k × StdDev(n))
Lower Band = Middle Band - (k × StdDev(n))
Where:
Interpretation:
PatternMeaningPrice touches upper bandOverbought; potential resistancePrice touches lower bandOversold; potential supportPrice breaks above upper bandStrong momentum; trend continuationPrice breaks below lower bandStrong momentum; trend continuationBands squeeze (narrowing)Low volatility; impending breakoutBands expand (widening)High volatility
KDJ is a derivative of the Stochastic Oscillator, widely used by Chinese futures traders.
text
Step 1: RSV = (C - L9) / (H9 - L9) × 100
Where C = today's close, L9 = lowest low of 9 periods, H9 = highest high of 9 periods
Step 2: K = (2/3 × K(yesterday)) + (1/3 × RSV)
Step 3: D = (2/3 × D(yesterday)) + (1/3 × K(today))
Step 4: J = (3 × K) - (2 × D)
Interpretation:
ValueMeaningK > DUptrendK < DDowntrendK/D/J > 80OverboughtK/D/J < 20OversoldGolden cross (K ↑ D)Buy signal (especially < 20)Death cross (K ↓ D)Sell signal (especially > 80)J > 100Top warning 🔴J < 0Bottom warning 🟢
Assign weights to get a combined signal:
IndicatorBuy SignalSell SignalWeightMACDDIF ↑ DEA, DIF > 0DIF ↓ DEA, DIF < 030%RSIRSI < 30 → oversoldRSI > 70 → overbought20%MAPrice > MA5 > MA10 > MA20Price < MA5 < MA10 < MA2025%BollingerPrice at/below lower bandPrice at/above upper band10%KDJK ↑ D < 20K ↓ D > 8015%
Overall:
Support levels (支撑位):
Resistance levels (压力位):
scripts/indicators.py#Core technical indicator calculation engine:
sma(data, period) — Simple Moving Averageema(data, period) — Exponential Moving Averagemacd(data) — MACD (DIF, DEA, histogram)rsi(data, period=14) — RSIbollinger(data, period=20, k=2) — Bollinger Bandskdj(data) — KDJ indicatorgolden_death_cross(short_ma, long_ma) — Detect 金叉/死叉composite_signal(data) — Combine all indicators → final signaltext
📉 沪深300 (IF2606) 技术分析
📊 均线系统
MA5: 3850.2 | MA10: 3820.5 | MA20: 3790.8
⚡ 金叉确认: MA5 上穿 MA10 ✅
📊 MACD (12,26,9)
DIF: +8.50 | DEA: +5.20 | 柱: +6.60
🟢 MACD金叉,DIF在零轴上方
📊 RSI(14): 62.5
⚪ 正常区间,偏强
📊 布林带 (20,2)
上轨: 3920.0 | 中轨: 3790.8 | 下轨: 3661.6
价格接近中轨,布林带略微扩张
📊 KDJ(9,3,3)
K: 68.2 | D: 62.5 | J: 79.6
⚠️ J值接近80,注意超买风险
━━━━━━━━━━━━━━━━━━━━━
🟢 BUY 信号 (评分: +65/100)
主要支撑: 3790 (MA20)
主要压力: 3850 (前高) / 3920 (布林上轨)
💡 建议: 短线偏多,注意J值高位回调风险
止损参考: 3780 (-0.5%)
scripts/indicators.py can be called directly for batch analysis