宏观数据模块
宏观数据模块提供大宗商品价格等宏观经济数据的查询功能。初始化
import { Reportify } from 'reportify-sdk';
const client = new Reportify({ apiKey: 'your-api-key' });
大宗商品价格
获取大宗商品价格数据,支持原油、黄金、天然气、白银、铂金。// 获取原油价格
const oil = await client.macro.commodities('oil', {
startDate: '2026-02-01',
endDate: '2026-02-09',
});
console.log(oil);
// [{ date: '2026-02-06T00:00:00+08:00', wti_co_sp: 63.77, brent_co_sp: 70.45 }, ...]
// 获取黄金价格
const gold = await client.macro.commodities('gold', {
startDate: '2026-02-01',
endDate: '2026-02-09',
});
console.log(gold);
// [{ date: '2026-02-06T00:00:00+08:00', lbma_pm_usd: 4948, sge_pm_cny: 1085.72 }, ...]
// 获取天然气价格
const gas = await client.macro.commodities('gas', {
startDate: '2026-02-01',
endDate: '2026-02-09',
});
参数说明
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| type | string | 是 | 商品类型:oil, gold, gas, silver, platinum |
| options.startDate | string | 是 | 开始日期(YYYY-MM-DD) |
| options.endDate | string | 是 | 结束日期(YYYY-MM-DD),起止间隔不超过 10 年 |
返回类型
返回Promise<CommodityData[]>,每个对象包含 date 字段和对应 type 的价格字段:
| type | 字段 | 描述 |
|---|---|---|
| oil | wti_co_sp, brent_co_sp | WTI/布伦特原油现货价(美元/桶) |
| gold | lbma_pm_usd, sge_pm_cny | 伦敦金(美元/盎司)/上海金(人民币) |
| gas | hh_ng_sp | 亨利港天然气(美元/百万英热单位) |
| silver | si_eur | 伦敦银(美元/盎司) |
| platinum | pl_usd | 伦敦铂金(美元/盎司) |
