Generate a structured global market snapshot report with stock indices and commodities data.
Use a two-layer design:
scripts/fetch_market.sh is a raw-fetch helper.Helper responsibilities:
Caller responsibilities:
scripts/fetch_market.sh.scripts/fetch_market.sh does not parse market payloads into final numeric results.
If Yahoo Finance fails (rate limit, error, no data), use Trading Economics as a fallback in the calling workflow.
scripts/fetch_market.sh only supports yahoo and sina; it does not implement a te mode.
For STAR Market Composite specifically, use Sina Finance as the helper-script fallback.
Callers should treat non-zero exit status as helper failure and read diagnostics from stderr rather than stdout.
Use these exact ticker symbols:
^GSPC^DJI^IXIC000001.SS399001.SZ000680.SS (NOT 000688.SS)^N225^BSESNGC=FSI=FCL=FHG=FUse scripts/fetch_market.sh or equivalent curl to fetch raw Yahoo Finance JSON:
curl -s "https://query1.finance.yahoo.com/v8/finance/chart/{TICKER}?interval=1d&range=5d" -H "User-Agent: Mozilla/5.0"
The caller must parse the returned JSON and compute the reported numbers.
If Yahoo Finance fails, use Trading Economics web fetch in the calling workflow rather than via scripts/fetch_market.sh:
https://tradingeconomics.com/united-states/stock-markethttps://tradingeconomics.com/china/stock-markethttps://tradingeconomics.com/china/stock-market (same page, different data)https://tradingeconomics.com/japan/stock-markethttps://tradingeconomics.com/india/stock-marketThe caller must fetch the page content and extract:
6762.88)6830.71)Calculate:
Example from US page:
Actual: 6762.88
Previous: 6830.71
Change: 6762.88 - 6830.71 = -67.83
Percent: -67.83 / 6830.71 * 100 = -0.99%
scripts/fetch_market.sh support)If Yahoo Finance fails for the supported China-market tickers below, use scripts/fetch_market.sh :
000001.SS -> sh000001399001.SZ -> sz399001000680.SS -> sh000680For STAR Market Composite specifically, this is the preferred helper-script fallback.
curl -s "https://hq.sinajs.cn/list=sh000680" \
-H "User-Agent: Mozilla/5.0" \
-H "Referer: https://finance.sina.com.cn" | iconv -f GB2312 -t UTF-8
scripts/fetch_market.sh follows this query shape and decodes with iconv when available. It returns decoded raw response text; the caller must parse the numeric fields.
var hq_str_sh000680="科创综指,open,prev_close,low,high,close,...
The caller must parse the response to extract:
Example:
科创综指,1771.6386,1774.0261,1744.2182,1782.4838,1744.0835,...
↑ ↑
previous current
Change: 1744.0835 - 1774.0261 = -29.94
Percent: -29.94 / 1774.0261 * 100 = -1.69%
NEVER use chartPreviousClose - it's often incorrect for Asian markets.
For Chinese indices (SSE, Shenzhen, STAR Market), the caller must:
range=5d to get multiple daysindicators.quote[0].close array from the returned payloadExample for SSE:
close array: [4182.59, 4122.68, 4082.47, 4108.57, 4124.19]
↑ today (last)
↑ previous (second to last)
Change: 4124.19 - 4108.57 = +15.62
After parsing and calculation, generate this exact format with timestamps:
Latest snapshot from the `market-global-snapshot` skill, generated at `UTC timestamp` and `China time`.
📊 Stock indices:
- 🇺🇸 S&P 500: `price` 📈/📉 `change` (`percent`)
- 🇺🇸 Dow Jones Industrial Average: `price` 📈/📉 `change` (`percent`)
- 🇺🇸 NASDAQ Composite: `price` 📈/📉 `change` (`percent`)
- 🇨🇳 SSE Composite: `price` 📈/📉 `change` (`percent`)
- 🇨🇳 Shenzhen Component Index: `price` 📈/📉 `change` (`percent`)
- 🇨🇳 STAR Market Composite: `price` 📈/📉 `change` (`percent`)
- 🇯🇵 Nikkei 225: `price` 📈/📉 `change` (`percent`)
- 🇮🇳 Sensex: `price` 📈/📉 `change` (`percent`)
🛢️ Commodities:
- 🟡 Gold: `price USD / troy oz` 📈/📉 `change` (`percent`)
- ⚪ Silver: `price USD / troy oz` 📈/📉 `change` (`percent`)
- 🛢️ Crude Oil: `price USD / barrel` 📈/📉 `change` (`percent`)
- 🟠 Copper: `price USD / lb` 📈/📉 `change` (`percent`)
If Yahoo Finance, Trading Economics, AND Sina all fail:
Treat source fetch failures and parse failures separately. If raw data is unavailable or unparsable, the caller should mark that item as "N/A".
To get previous day's data instead of today, the caller should:
Example:
close array: [4124.19, 4108.57, 4082.47, 4122.68, 4182.59]
↑ ↑
yesterday today
共 3 个版本