longbridge-candlestick
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineselongbridge-candlestick
longbridge-candlestick
Identifies 15 classic K-line candlestick patterns from recent OHLCV data and produces a composite bullish / bearish / neutral signal with per-pattern explanations.
Response language: match the user's input language — Simplified Chinese / Traditional Chinese / English.
从最新的OHLCV数据中识别15种经典K线蜡烛图形态,并生成包含各形态解释的综合看涨/看跌/中性信号。
回复语言:匹配用户输入语言——简体中文 / 繁体中文 / 英文。
When to use
使用场景
- "NVDA 最近有什么 K 线形态", "700.HK 是否出现锤子线"
- "TSLA candlestick patterns", "看看吞没形态", "有没有早晨之星"
- "600519.SH K線形態分析", "是否出現三白兵"
- "NVDA 最近有什么 K 线形态", "700.HK 是否出现锤子线"
- "TSLA candlestick patterns", "看看吞没形态", "有没有早晨之星"
- "600519.SH K線形態分析", "是否出現三白兵"
Workflow
工作流程
- Resolve the symbol to format.
<CODE>.<MARKET> - Fetch 200 daily candles:
bash
longbridge kline <SYMBOL> --period day --count 200 --format json - Run the Python analysis below to identify patterns and compute a composite score.
- Report detected patterns (most recent first), each with date, name, and interpretation. Summarise with a composite signal.
- 将代码解析为 格式。
<CODE>.<MARKET> - 获取200条日线数据:
bash
longbridge kline <SYMBOL> --period day --count 200 --format json - 运行下方的Python分析代码以识别形态并计算综合得分。
- 报告检测到的形态(按最新时间排序),每条包含日期、名称和解读。最后总结综合信号。
CLI
命令行界面(CLI)
bash
longbridge kline NVDA.US --period day --count 200 --format json
longbridge kline 700.HK --period day --count 200 --format json
longbridge kline 600519.SH --period day --count 200 --format jsonRun to verify current flag names and defaults.
longbridge kline --helpbash
longbridge kline NVDA.US --period day --count 200 --format json
longbridge kline 700.HK --period day --count 200 --format json
longbridge kline 600519.SH --period day --count 200 --format json运行 查看当前参数名称及默认值。
longbridge kline --helpPython analysis
Python分析代码
python
import pandas as pd, json, sys
data = json.loads(sys.stdin.read()) # list of OHLCV dicts
df = pd.DataFrame(data)
df = df.rename(columns={"open": "o", "high": "h", "low": "l", "close": "c", "volume": "v"})
df[["o","h","l","c","v"]] = df[["o","h","l","c","v"]].apply(pd.to_numeric)
body = (df["c"] - df["o"]).abs()
rng = df["h"] - df["l"]
upper = df.apply(lambda r: r["h"] - max(r["c"], r["o"]), axis=1)
lower = df.apply(lambda r: min(r["c"], r["o"]) - r["l"], axis=1)
bull = df["c"] > df["o"]
signals, score = [], 0python
import pandas as pd, json, sys
data = json.loads(sys.stdin.read()) # list of OHLCV dicts
df = pd.DataFrame(data)
df = df.rename(columns={"open": "o", "high": "h", "low": "l", "close": "c", "volume": "v"})
df[["o","h","l","c","v"]] = df[["o","h","l","c","v"]].apply(pd.to_numeric)
body = (df["c"] - df["o"]).abs()
rng = df["h"] - df["l"]
upper = df.apply(lambda r: r["h"] - max(r["c"], r["o"]), axis=1)
lower = df.apply(lambda r: min(r["c"], r["o"]) - r["l"], axis=1)
bull = df["c"] > df["o"]
signals, score = [], 0--- single-bar patterns (check last 5 bars) ---
--- single-bar patterns (check last 5 bars) ---
for i in range(max(0, len(df)-5), len(df)):
r = df.iloc[i]; b = body.iloc[i]; u = upper.iloc[i]; lo = lower.iloc[i]; rg = rng.iloc[i]
# Doji
if b < 0.05 * rg:
signals.append((df["time"].iloc[i], "十字星/Doji", 0))
# Hammer (bullish reversal after downtrend)
elif lo > 2b and u < 0.1b and not bull.iloc[i]:
signals.append((df["time"].iloc[i], "锤子线/Hammer", +1))
elif lo > 2b and u < 0.1b and bull.iloc[i]:
signals.append((df["time"].iloc[i], "锤子线/Hammer(bullish)", +1))
# Hanging Man (bearish)
elif lo > 2b and u < 0.1b and i > 0 and df["c"].iloc[i-1] < df["c"].iloc[i]:
signals.append((df["time"].iloc[i], "吊颈线/Hanging Man", -1))
# Shooting Star (bearish)
elif u > 2b and lo < 0.1b and bull.iloc[i-1] if i > 0 else False:
signals.append((df["time"].iloc[i], "射击之星/Shooting Star", -1))
# Inverted Hammer (bullish)
elif u > 2b and lo < 0.1b:
signals.append((df["time"].iloc[i], "倒锤线/Inverted Hammer", +1))
# Marubozu bullish
elif b > 0.9rg and bull.iloc[i]:
signals.append((df["time"].iloc[i], "光头光脚阳线/Bullish Marubozu", +1))
# Marubozu bearish
elif b > 0.9rg and not bull.iloc[i]:
signals.append((df["time"].iloc[i], "光头光脚阴线/Bearish Marubozu", -1))
for i in range(max(0, len(df)-5), len(df)):
r = df.iloc[i]; b = body.iloc[i]; u = upper.iloc[i]; lo = lower.iloc[i]; rg = rng.iloc[i]
# Doji
if b < 0.05 * rg:
signals.append((df["time"].iloc[i], "十字星/Doji", 0))
# Hammer (bullish reversal after downtrend)
elif lo > 2b and u < 0.1b and not bull.iloc[i]:
signals.append((df["time"].iloc[i], "锤子线/Hammer", +1))
elif lo > 2b and u < 0.1b and bull.iloc[i]:
signals.append((df["time"].iloc[i], "锤子线/Hammer(bullish)", +1))
# Hanging Man (bearish)
elif lo > 2b and u < 0.1b and i > 0 and df["c"].iloc[i-1] < df["c"].iloc[i]:
signals.append((df["time"].iloc[i], "吊颈线/Hanging Man", -1))
# Shooting Star (bearish)
elif u > 2b and lo < 0.1b and bull.iloc[i-1] if i > 0 else False:
signals.append((df["time"].iloc[i], "射击之星/Shooting Star", -1))
# Inverted Hammer (bullish)
elif u > 2b and lo < 0.1b:
signals.append((df["time"].iloc[i], "倒锤线/Inverted Hammer", +1))
# Marubozu bullish
elif b > 0.9rg and bull.iloc[i]:
signals.append((df["time"].iloc[i], "光头光脚阳线/Bullish Marubozu", +1))
# Marubozu bearish
elif b > 0.9rg and not bull.iloc[i]:
signals.append((df["time"].iloc[i], "光头光脚阴线/Bearish Marubozu", -1))
--- two-bar patterns ---
--- two-bar patterns ---
for i in range(max(1, len(df)-5), len(df)):
p, c_ = df.iloc[i-1], df.iloc[i]
pb, cb = body.iloc[i-1], body.iloc[i]
# Bullish engulfing
if not bull.iloc[i-1] and bull.iloc[i] and c_["o"] < p["c"] and c_["c"] > p["o"]:
signals.append((df["time"].iloc[i], "看涨吞没/Bullish Engulfing", +2)); score += 2
# Bearish engulfing
elif bull.iloc[i-1] and not bull.iloc[i] and c_["o"] > p["c"] and c_["c"] < p["o"]:
signals.append((df["time"].iloc[i], "看跌吞没/Bearish Engulfing", -2)); score -= 2
# Piercing line
elif not bull.iloc[i-1] and bull.iloc[i] and c_["o"] < p["l"] and c_["c"] > (p["o"]+p["c"])/2:
signals.append((df["time"].iloc[i], "刺透线/Piercing Line", +1)); score += 1
# Dark cloud cover
elif bull.iloc[i-1] and not bull.iloc[i] and c_["o"] > p["h"] and c_["c"] < (p["o"]+p["c"])/2:
signals.append((df["time"].iloc[i], "乌云盖顶/Dark Cloud Cover", -1)); score -= 1
for i in range(max(1, len(df)-5), len(df)):
p, c_ = df.iloc[i-1], df.iloc[i]
pb, cb = body.iloc[i-1], body.iloc[i]
# Bullish engulfing
if not bull.iloc[i-1] and bull.iloc[i] and c_["o"] < p["c"] and c_["c"] > p["o"]:
signals.append((df["time"].iloc[i], "看涨吞没/Bullish Engulfing", +2)); score += 2
# Bearish engulfing
elif bull.iloc[i-1] and not bull.iloc[i] and c_["o"] > p["c"] and c_["c"] < p["o"]:
signals.append((df["time"].iloc[i], "看跌吞没/Bearish Engulfing", -2)); score -= 2
# Piercing line
elif not bull.iloc[i-1] and bull.iloc[i] and c_["o"] < p["l"] and c_["c"] > (p["o"]+p["c"])/2:
signals.append((df["time"].iloc[i], "刺透线/Piercing Line", +1)); score += 1
# Dark cloud cover
elif bull.iloc[i-1] and not bull.iloc[i] and c_["o"] > p["h"] and c_["c"] < (p["o"]+p["c"])/2:
signals.append((df["time"].iloc[i], "乌云盖顶/Dark Cloud Cover", -1)); score -= 1
--- three-bar patterns ---
--- three-bar patterns ---
for i in range(max(2, len(df)-5), len(df)):
a, b_, c_ = df.iloc[i-2], df.iloc[i-1], df.iloc[i]
sb = body.iloc[i-1]
# Morning star
if not bull.iloc[i-2] and sb < 0.3*(body.iloc[i-2]) and bull.iloc[i] and c_["c"] > (a["o"]+a["c"])/2:
signals.append((df["time"].iloc[i], "早晨之星/Morning Star", +2)); score += 2
# Evening star
elif bull.iloc[i-2] and sb < 0.3*(body.iloc[i-2]) and not bull.iloc[i] and c_["c"] < (a["o"]+a["c"])/2:
signals.append((df["time"].iloc[i], "暮色之星/Evening Star", -2)); score -= 2
# Three white soldiers
elif bull.iloc[i-2] and bull.iloc[i-1] and bull.iloc[i] and c_["c"]>b_["c"]>a["c"]:
signals.append((df["time"].iloc[i], "三白兵/Three White Soldiers", +2)); score += 2
# Three black crows
elif not bull.iloc[i-2] and not bull.iloc[i-1] and not bull.iloc[i] and c_["c"]<b_["c"]<a["c"]:
signals.append((df["time"].iloc[i], "三黑鸦/Three Black Crows", -2)); score -= 2
for i in range(max(2, len(df)-5), len(df)):
a, b_, c_ = df.iloc[i-2], df.iloc[i-1], df.iloc[i]
sb = body.iloc[i-1]
# Morning star
if not bull.iloc[i-2] and sb < 0.3*(body.iloc[i-2]) and bull.iloc[i] and c_["c"] > (a["o"]+a["c"])/2:
signals.append((df["time"].iloc[i], "早晨之星/Morning Star", +2)); score += 2
# Evening star
elif bull.iloc[i-2] and sb < 0.3*(body.iloc[i-2]) and not bull.iloc[i] and c_["c"] < (a["o"]+a["c"])/2:
signals.append((df["time"].iloc[i], "暮色之星/Evening Star", -2)); score -= 2
# Three white soldiers
elif bull.iloc[i-2] and bull.iloc[i-1] and bull.iloc[i] and c_["c"]>b_["c"]>a["c"]:
signals.append((df["time"].iloc[i], "三白兵/Three White Soldiers", +2)); score += 2
# Three black crows
elif not bull.iloc[i-2] and not bull.iloc[i-1] and not bull.iloc[i] and c_["c"]<b_["c"]<a["c"]:
signals.append((df["time"].iloc[i], "三黑鸦/Three Black Crows", -2)); score -= 2
add single-bar scores
add single-bar scores
for _, _, s in signals:
score += s
composite = "看多/Bullish" if score >= 2 else ("看空/Bearish" if score <= -2 else "中性/Neutral")
print(f"Composite score: {score} → {composite}")
for ts, name, s in signals:
print(f" {ts} {name} ({'+'if s>=0 else ''}{s})")
undefinedfor _, _, s in signals:
score += s
composite = "看多/Bullish" if score >= 2 else ("看空/Bearish" if score <= -2 else "中性/Neutral")
print(f"Composite score: {score} → {composite}")
for ts, name, s in signals:
print(f" {ts} {name} ({'+'if s>=0 else ''}{s})")
undefinedOutput
输出格式
Report format (3 languages):
| 字段 / 欄位 / Field | 简体 / 繁體 / English |
|---|---|
| 检测到的形态 | 检测到的形态 / 檢測到的形態 / Detected patterns |
| 综合信号 | 看多 / 看空 / 中性 |
| 解释 | 解释 / 解釋 / Explanation |
Present at most 5 most-recent patterns. Conclude with the composite signal and a one-sentence interpretation.
报告格式(三种语言):
| 字段 / 欄位 / Field | 简体 / 繁體 / English |
|---|---|
| 检测到的形态 | 检测到的形态 / 檢測到的形態 / Detected patterns |
| 综合信号 | 看多 / 看空 / 中性 |
| 解释 | 解释 / 解釋 / Explanation |
最多展示5种最新形态。最后给出综合信号及一句话解读。
Error handling
错误处理
| Situation | 简体回复 / 繁體回覆 / English reply |
|---|---|
| 请安装 longbridge-terminal / 請安裝 longbridge-terminal / Install longbridge-terminal first |
stderr | 请运行 |
| Other stderr | 直接展示错误信息 / 直接顯示錯誤訊息 / Surface error verbatim |
| 场景 | 简体回复 / 繁體回覆 / English reply |
|---|---|
| 请安装 longbridge-terminal / 請安裝 longbridge-terminal / Install longbridge-terminal first |
stderr | 请运行 |
| Other stderr | 直接展示错误信息 / 直接顯示錯誤訊息 / Surface error verbatim |
MCP fallback
MCP fallback方案
If binary is unavailable, call with equivalent parameters. Surface the same analysis.
longbridgemcp__longbridge__kline如果二进制文件不可用,请使用等效参数调用,执行相同分析。
longbridgemcp__longbridge__klineRelated skills
相关技能
- — raw OHLCV data and charting
longbridge-kline - — indicator-based signals (MACD, RSI, KDJ, etc.)
longbridge-technical - — Ichimoku Cloud system
longbridge-ichimoku - — real-time price and reference data
longbridge-quote
- — 原始OHLCV数据及绘图
longbridge-kline - — 基于指标的信号(MACD、RSI、KDJ等)
longbridge-technical - — 一目均衡表系统
longbridge-ichimoku - — 实时价格及参考数据
longbridge-quote