Skip to content

Instantly share code, notes, and snippets.

@discountry
Created March 10, 2026 14:22
Show Gist options
  • Select an option

  • Save discountry/fb0a690a7ca01a7dbe3cd7d0082f39c2 to your computer and use it in GitHub Desktop.

Select an option

Save discountry/fb0a690a7ca01a7dbe3cd7d0082f39c2 to your computer and use it in GitHub Desktop.
name description
get-kline-prediction
Fetch and summarize K-line prediction reports from http://localhost:3000. Use when the user asks for a token price prediction, forecast, K-line prediction, price outlook, market forecast, or mentions 'prediction report', 'forecast report', 'kline prediction', 'price prediction', or wants to know the predicted price movement for a specific token. Covers fetching the latest AI+algorithmic forecast, summarizing outlook, drivers, risks, theory notes, and predicted candlestick data.

Get K-line Prediction Report

Fetch the latest AI-powered K-line prediction report for a token from http://localhost:3000 and present a clean, structured summary.

API Endpoint

GET http://localhost:3000/api/reports?symbol=<SYMBOL>

Query Parameters

Param Required Description
symbol Yes Token symbol (e.g. ETH, BTC, SOL). Aliases: token, q
chainIndex No Filter by chain (e.g. 1=Ethereum, 501=Solana, 8453=Base, 56=BNB Chain, 42161=Arbitrum, 10=Optimism)
bar No Filter by timeframe: 5m, 15m, 1H, 4H, 1D

Response Shape (success)

{
  "ok": true,
  "query": { "symbol": "ETH", "chainIndex": null, "bar": null },
  "report": {
    "metadata": {
      "id": "...",
      "savedAt": "ISO",
      "generatedAt": "ISO",
      "tokenSymbol": "ETH",
      "tokenName": "Ethereum",
      "chainName": "Ethereum",
      "bar": "4H",
      "forecastBars": 24,
      "source": "gemini",
      "publicUrl": "/data/predictions/eth/...",
      "downloadUrl": "http://localhost:3000/data/predictions/eth/..."
    },
    "forecast": {
      "token": { "tokenSymbol", "tokenName", "chainName", "price", "change24h", "marketCap", "liquidity", "holders" },
      "settings": { "bar", "historyBars", "forecastBars", "theories", "thesis" },
      "metrics": { "lastClose", "support", "resistance", "rsi14", "regime", "realizedVolatility", "atrPercent", "compositeSignal", ... },
      "summary": { "headline", "narrative", "outlook", "confidence" },
      "drivers": ["..."],
      "risks": ["..."],
      "theoryNotes": [{ "theory": "trend", "note": "..." }],
      "forecast": [{ "time", "open", "high", "low", "close", "volume", "confidence", "driver", "regime" }],
      "source": "gemini",
      "generatedAt": "ISO"
    }
  }
}

Error Responses

Status Meaning
400 Missing or invalid symbol / bar
404 No prediction report found for this token

Workflow

Step 1: Identify Token

  • Extract the token symbol from the user's request.
  • If unclear, ask which token they want a prediction for.
  • If the user specifies a chain or timeframe, include chainIndex and/or bar.

Step 2: Fetch Report

Use curl or the Shell tool:

curl -s "http://localhost:3000/api/reports?symbol=ETH"

With optional filters:

curl -s "http://localhost:3000/api/reports?symbol=ETH&bar=4H&chainIndex=1"

Parse the JSON response. If ok is not true or HTTP status is 404, inform the user no report is available for this token.

Step 3: Format and Present

Use the output template below. Extract data from report.forecast (the ForecastResponse object).

Output Template

Present the report using this structure. Adapt field labels to match the user's language preference. All monetary values use appropriate precision.

## <token.tokenSymbol> K-line Prediction Report

**Token**: <token.tokenName> (<token.tokenSymbol>) on <token.chainName>
**Current Price**: $<token.price>  |  **24h Change**: <token.change24h>%
**Market Cap**: $<marketCap>  |  **Liquidity**: $<liquidity>  |  **Holders**: <holders>

---

### Forecast Summary

> <summary.headline>

**Outlook**: <summary.outlook>  |  **Confidence**: <summary.confidence * 100>%
**Timeframe**: <settings.forecastBars> bars @ <settings.bar>  |  **Model**: <source>
**Generated**: <generatedAt>

<summary.narrative>

---

### Key Drivers
1. <drivers[0]>
2. <drivers[1]>
...

### Risk Factors
1. <risks[0]>
2. <risks[1]>
...

---

### Technical Snapshot

| Metric | Value |
|---|---|
| Last Close | $<metrics.lastClose> |
| Support | $<metrics.support> |
| Resistance | $<metrics.resistance> |
| RSI(14) | <metrics.rsi14> |
| Regime | <metrics.regime> |
| Realized Vol | <metrics.realizedVolatility * 100>% |
| ATR% | <metrics.atrPercent * 100>% |
| Composite Signal | <metrics.compositeSignal> |

---

### Theory Analysis
<For each theoryNote>
- **<THEORY_OPTIONS label for theory>**: <note>

---

### Predicted K-lines (first 5 & last 3)

| # | Time | Open | High | Low | Close | Conf | Driver |
|---|---|---|---|---|---|---|---|
| 1 | <formatted time> | ... | ... | ... | ... | <confidence>% | <driver> |
...

**Price Range**: $<min forecast low> ~ $<max forecast high>
**Final Predicted Close**: $<last forecast close>
**Avg Confidence**: <mean confidence * 100>%

---

### Report Links
- Full report JSON: <metadata.downloadUrl>

Formatting Rules

  1. Outlook emoji: bullish β†’ πŸ“ˆ, bearish β†’ πŸ“‰, sideways β†’ ➑️, volatile β†’ 🌊
  2. Confidence color: β‰₯70% strong, 40-70% moderate, <40% weak
  3. Time formatting: Convert Unix ms timestamps to human-readable (e.g. 2025-03-10 14:00 UTC)
  4. Price precision: Match the token's price magnitude (2 decimals for >$1000, 4 for >$1, 6 for <$1, 8 for <$0.01)
  5. Large numbers: Use K/M/B abbreviations for market cap and liquidity (e.g. $1.2B, $45.3M)
  6. Theory labels: Map theory IDs to display names: trendβ†’θΆ‹εŠΏθ·Ÿιš, mean-reversionβ†’ε‡ε€Όε›žε½’, support-resistanceβ†’ζ”―ζ’‘ι˜»εŠ›, volume-priceβ†’ι‡δ»·εˆ†ζž, wyckoffβ†’Wyckoff, elliottβ†’θ‰Ύη•₯η‰Ήζ³’ζ΅ͺ, volatilityβ†’ζ³’εŠ¨ηŽ‡
  7. K-line table: Show first 5 and last 3 bars to keep output concise. If total bars ≀ 8, show all.
  8. Disclaimer: Always append: This is an experimental AI scenario projection, not investment advice.

Edge Cases

  • 404 / report not found: "No prediction report found for . The token may not have been analyzed yet. You can trigger a prediction from the http://localhost:3000 dashboard."
  • Network error: Retry once, then inform the user.
  • Empty forecast array: Report exists but forecast is empty β€” note this is unusual and suggest re-running prediction.
  • Stale report: If generatedAt is older than 24 hours, note that the report may be outdated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment