oilpriceapi 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +201 -19
- package/dist/cjs/client.js +139 -19
- package/dist/cjs/index.js +17 -3
- package/dist/cjs/resources/analytics.js +99 -137
- package/dist/cjs/resources/bunker-fuels.js +37 -23
- package/dist/cjs/resources/data-sources.js +13 -12
- package/dist/cjs/resources/ei/frac-focus.js +16 -6
- package/dist/cjs/resources/ei/well-permits.js +18 -6
- package/dist/cjs/resources/forecasts.js +11 -5
- package/dist/cjs/resources/futures.js +192 -1
- package/dist/cjs/resources/indicators.js +79 -0
- package/dist/cjs/resources/raw.js +128 -0
- package/dist/cjs/resources/rig-counts.js +5 -2
- package/dist/cjs/resources/spreads.js +105 -0
- package/dist/cjs/resources/storage.js +5 -5
- package/dist/cjs/resources/streaming.js +350 -0
- package/dist/cjs/resources/webhooks.js +3 -14
- package/dist/cjs/version.js +1 -1
- package/dist/client.d.ts +97 -1
- package/dist/client.js +139 -19
- package/dist/index.d.ts +12 -3
- package/dist/index.js +5 -0
- package/dist/resources/analytics.d.ts +147 -214
- package/dist/resources/analytics.js +99 -137
- package/dist/resources/bunker-fuels.d.ts +35 -12
- package/dist/resources/bunker-fuels.js +37 -23
- package/dist/resources/data-sources.d.ts +31 -31
- package/dist/resources/data-sources.js +13 -12
- package/dist/resources/ei/frac-focus.d.ts +23 -9
- package/dist/resources/ei/frac-focus.js +16 -6
- package/dist/resources/ei/well-permits.d.ts +25 -9
- package/dist/resources/ei/well-permits.js +18 -6
- package/dist/resources/forecasts.d.ts +4 -1
- package/dist/resources/forecasts.js +11 -5
- package/dist/resources/futures.d.ts +178 -1
- package/dist/resources/futures.js +190 -0
- package/dist/resources/indicators.d.ts +170 -0
- package/dist/resources/indicators.js +75 -0
- package/dist/resources/raw.d.ts +94 -0
- package/dist/resources/raw.js +124 -0
- package/dist/resources/rig-counts.js +5 -2
- package/dist/resources/spreads.d.ts +121 -0
- package/dist/resources/spreads.js +101 -0
- package/dist/resources/storage.d.ts +5 -4
- package/dist/resources/storage.js +5 -5
- package/dist/resources/streaming.d.ts +272 -0
- package/dist/resources/streaming.js +342 -0
- package/dist/resources/webhooks.d.ts +37 -23
- package/dist/resources/webhooks.js +3 -14
- package/dist/types.d.ts +41 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -1
|
@@ -3,166 +3,152 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Access advanced analytics including performance metrics, statistical analysis,
|
|
5
5
|
* correlations, trend detection, spreads, and forecasts.
|
|
6
|
+
*
|
|
7
|
+
* NOTE ON PARAMETERS: The OilPriceAPI analytics controller reads commodity
|
|
8
|
+
* identifiers as `code` / `code1` / `code2` and the lookback window as `period`
|
|
9
|
+
* (in days). Earlier versions of this SDK sent `commodity` / `commodity1` /
|
|
10
|
+
* `commodity2` / `days`, which the API silently ignored (and `correlation`
|
|
11
|
+
* returned "code1 and code2 parameters are required"). These methods now send
|
|
12
|
+
* the parameter names the controller actually reads.
|
|
6
13
|
*/
|
|
7
14
|
import type { OilPriceAPI } from "../client.js";
|
|
8
15
|
/**
|
|
9
|
-
* Performance metrics for
|
|
16
|
+
* Performance metrics for the authenticated user's API usage.
|
|
17
|
+
*
|
|
18
|
+
* NOTE: `/v1/analytics/performance` returns the user's API usage analytics
|
|
19
|
+
* (request counts, error rate, endpoint breakdown) for a dashboard, NOT
|
|
20
|
+
* commodity price performance. It accepts a `range` of `7d` | `30d` | `90d`.
|
|
10
21
|
*/
|
|
11
22
|
export interface PerformanceMetrics {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/** Price volatility (standard deviation) */
|
|
19
|
-
volatility: number;
|
|
20
|
-
/** Percentage return over period */
|
|
21
|
-
return_percent: number;
|
|
22
|
-
/** Highest price in period */
|
|
23
|
-
high: number;
|
|
24
|
-
/** Lowest price in period */
|
|
25
|
-
low: number;
|
|
26
|
-
/** ISO timestamp */
|
|
27
|
-
timestamp: string;
|
|
23
|
+
overview?: Record<string, unknown>;
|
|
24
|
+
dailyUsage?: Array<Record<string, unknown>>;
|
|
25
|
+
hourlyDistribution?: Array<Record<string, unknown>>;
|
|
26
|
+
endpointBreakdown?: Array<Record<string, unknown>>;
|
|
27
|
+
geographicData?: Array<Record<string, unknown>>;
|
|
28
|
+
[key: string]: unknown;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Options for performance query
|
|
31
32
|
*/
|
|
32
33
|
export interface PerformanceOptions {
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
/** Number of days to analyze (default: 30) */
|
|
36
|
-
days?: number;
|
|
34
|
+
/** Time range for usage analytics: '7d' | '30d' | '90d' (default: '30d') */
|
|
35
|
+
range?: "7d" | "30d" | "90d";
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
39
38
|
* Statistical analysis results
|
|
40
39
|
*/
|
|
41
40
|
export interface StatisticalAnalysis {
|
|
42
41
|
/** Commodity code */
|
|
43
|
-
|
|
42
|
+
code: string;
|
|
44
43
|
/** Time period analyzed (in days) */
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
std_dev: number;
|
|
52
|
-
/** Variance */
|
|
53
|
-
variance: number;
|
|
54
|
-
/** Minimum price */
|
|
55
|
-
min: number;
|
|
56
|
-
/** Maximum price */
|
|
57
|
-
max: number;
|
|
58
|
-
/** 25th percentile */
|
|
59
|
-
percentile_25?: number;
|
|
60
|
-
/** 75th percentile */
|
|
61
|
-
percentile_75?: number;
|
|
62
|
-
/** Skewness */
|
|
63
|
-
skewness?: number;
|
|
64
|
-
/** Kurtosis */
|
|
65
|
-
kurtosis?: number;
|
|
66
|
-
/** ISO timestamp */
|
|
67
|
-
timestamp: string;
|
|
44
|
+
period: number;
|
|
45
|
+
/** Statistical metrics computed for the commodity */
|
|
46
|
+
statistics: Record<string, unknown>;
|
|
47
|
+
/** Tier of the requesting user */
|
|
48
|
+
tier?: string;
|
|
49
|
+
[key: string]: unknown;
|
|
68
50
|
}
|
|
69
51
|
/**
|
|
70
52
|
* Correlation analysis between two commodities
|
|
71
53
|
*/
|
|
72
54
|
export interface CorrelationAnalysis {
|
|
55
|
+
/** Response type: 'analysis' | 'rolling' | 'matrix' */
|
|
56
|
+
type?: string;
|
|
73
57
|
/** First commodity code */
|
|
74
|
-
|
|
58
|
+
code1?: string;
|
|
75
59
|
/** Second commodity code */
|
|
76
|
-
|
|
60
|
+
code2?: string;
|
|
77
61
|
/** Time period analyzed (in days) */
|
|
78
|
-
|
|
62
|
+
period?: number;
|
|
79
63
|
/** Pearson correlation coefficient (-1 to 1) */
|
|
80
|
-
correlation
|
|
64
|
+
correlation?: number;
|
|
81
65
|
/** Correlation strength description */
|
|
82
|
-
strength?:
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
66
|
+
strength?: string;
|
|
67
|
+
/** Tier of the requesting user */
|
|
68
|
+
tier?: string;
|
|
69
|
+
[key: string]: unknown;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Options for correlation query
|
|
73
|
+
*/
|
|
74
|
+
export interface CorrelationOptions {
|
|
75
|
+
/** Lookback window in days (default: 30) */
|
|
76
|
+
period?: number;
|
|
77
|
+
/** Correlation variant: 'analysis' (default), 'rolling', or 'matrix' */
|
|
78
|
+
type?: "analysis" | "rolling" | "matrix";
|
|
79
|
+
/** Rolling window size in days (only used when type === 'rolling') */
|
|
80
|
+
window?: number;
|
|
81
|
+
/** Comma-separated codes for a correlation matrix (only when type === 'matrix') */
|
|
82
|
+
codes?: string[];
|
|
87
83
|
}
|
|
88
84
|
/**
|
|
89
85
|
* Trend analysis results
|
|
90
86
|
*/
|
|
91
87
|
export interface TrendAnalysis {
|
|
88
|
+
/** Response type: 'analysis' | 'sma' | 'ema' | 'rsi' | 'levels' */
|
|
89
|
+
type?: string;
|
|
92
90
|
/** Commodity code */
|
|
93
|
-
|
|
91
|
+
code?: string;
|
|
94
92
|
/** Time period analyzed (in days) */
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
|
|
93
|
+
period?: number;
|
|
94
|
+
/** Tier of the requesting user */
|
|
95
|
+
tier?: string;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Options for trend query
|
|
100
|
+
*/
|
|
101
|
+
export interface TrendOptions {
|
|
102
|
+
/** Lookback window in days (default: 30) */
|
|
103
|
+
period?: number;
|
|
104
|
+
/** Trend variant: 'analysis' (default), 'sma', 'ema', 'rsi', or 'levels' */
|
|
105
|
+
type?: "analysis" | "sma" | "ema" | "rsi" | "levels";
|
|
106
|
+
/** Moving-average / indicator window (used by sma/ema/rsi) */
|
|
107
|
+
window?: number;
|
|
110
108
|
}
|
|
111
109
|
/**
|
|
112
|
-
* Spread analysis
|
|
110
|
+
* Spread analysis for a named commodity spread (e.g. 'wti_brent')
|
|
113
111
|
*/
|
|
114
112
|
export interface SpreadAnalysis {
|
|
115
|
-
/**
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
spread_volatility?: number;
|
|
125
|
-
/** Z-score of current spread */
|
|
126
|
-
z_score?: number;
|
|
127
|
-
/** ISO timestamp */
|
|
128
|
-
timestamp: string;
|
|
113
|
+
/** Response type: 'current' | 'historical' */
|
|
114
|
+
type?: string;
|
|
115
|
+
/** The named spread analyzed */
|
|
116
|
+
spread?: string;
|
|
117
|
+
/** Time period analyzed (in days) */
|
|
118
|
+
period?: number;
|
|
119
|
+
/** Tier of the requesting user */
|
|
120
|
+
tier?: string;
|
|
121
|
+
[key: string]: unknown;
|
|
129
122
|
}
|
|
130
123
|
/**
|
|
131
|
-
*
|
|
124
|
+
* Options for spread query
|
|
132
125
|
*/
|
|
133
|
-
export interface
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
|
|
138
|
-
/** Lower bound of confidence interval */
|
|
139
|
-
lower_bound?: number;
|
|
140
|
-
/** Upper bound of confidence interval */
|
|
141
|
-
upper_bound?: number;
|
|
142
|
-
/** Confidence level (e.g., 0.95 for 95%) */
|
|
143
|
-
confidence?: number;
|
|
126
|
+
export interface SpreadOptions {
|
|
127
|
+
/** Lookback window in days (default: 30) */
|
|
128
|
+
period?: number;
|
|
129
|
+
/** Spread variant: 'current' (default) or 'historical' */
|
|
130
|
+
type?: "current" | "historical";
|
|
144
131
|
}
|
|
145
132
|
/**
|
|
146
133
|
* Price forecast
|
|
147
134
|
*/
|
|
148
135
|
export interface PriceForecast {
|
|
149
136
|
/** Commodity code */
|
|
150
|
-
|
|
151
|
-
/** Forecast
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
timestamp: string;
|
|
137
|
+
code?: string;
|
|
138
|
+
/** Forecast method used */
|
|
139
|
+
method?: string;
|
|
140
|
+
/** Tier of the requesting user */
|
|
141
|
+
tier?: string;
|
|
142
|
+
[key: string]: unknown;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Options for forecast query
|
|
146
|
+
*/
|
|
147
|
+
export interface ForecastOptions {
|
|
148
|
+
/** Forecast method (default: 'ema') */
|
|
149
|
+
method?: string;
|
|
150
|
+
/** Lookback window in days (default: 90) */
|
|
151
|
+
period?: number;
|
|
166
152
|
}
|
|
167
153
|
/**
|
|
168
154
|
* Analytics Resource
|
|
@@ -176,13 +162,8 @@ export interface PriceForecast {
|
|
|
176
162
|
*
|
|
177
163
|
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
178
164
|
*
|
|
179
|
-
* //
|
|
180
|
-
* const
|
|
181
|
-
* console.log(`30-day return: ${perf.return_percent}%`);
|
|
182
|
-
* console.log(`Volatility: ${perf.volatility}`);
|
|
183
|
-
*
|
|
184
|
-
* // Analyze correlation
|
|
185
|
-
* const corr = await client.analytics.correlation('WTI_USD', 'BRENT_CRUDE_USD', 90);
|
|
165
|
+
* // Analyze correlation between two commodities (90-day window)
|
|
166
|
+
* const corr = await client.analytics.correlation('WTI_USD', 'BRENT_CRUDE_USD', { period: 90 });
|
|
186
167
|
* console.log(`Correlation: ${corr.correlation}`);
|
|
187
168
|
* ```
|
|
188
169
|
*/
|
|
@@ -190,136 +171,88 @@ export declare class AnalyticsResource {
|
|
|
190
171
|
private client;
|
|
191
172
|
constructor(client: OilPriceAPI);
|
|
192
173
|
/**
|
|
193
|
-
* Get
|
|
194
|
-
*
|
|
195
|
-
* Returns key performance indicators including returns, volatility,
|
|
196
|
-
* and price range over a specified period.
|
|
197
|
-
*
|
|
198
|
-
* @param options - Analysis parameters
|
|
199
|
-
* @returns Performance metrics
|
|
174
|
+
* Get the authenticated user's API usage analytics for the dashboard.
|
|
200
175
|
*
|
|
201
|
-
*
|
|
176
|
+
* Maps to `GET /v1/analytics/performance`, which reads a `range`
|
|
177
|
+
* parameter (`7d` | `30d` | `90d`).
|
|
202
178
|
*
|
|
203
|
-
* @
|
|
204
|
-
*
|
|
205
|
-
* const metrics = await client.analytics.performance({
|
|
206
|
-
* commodity: 'WTI_USD',
|
|
207
|
-
* days: 30
|
|
208
|
-
* });
|
|
209
|
-
* console.log(`Return: ${metrics.return_percent}%`);
|
|
210
|
-
* console.log(`Volatility: ${metrics.volatility}`);
|
|
211
|
-
* console.log(`High: $${metrics.high}, Low: $${metrics.low}`);
|
|
212
|
-
* ```
|
|
179
|
+
* @param options - `{ range }` (default range '30d')
|
|
180
|
+
* @returns Usage analytics (overview, daily usage, endpoint breakdown, ...)
|
|
213
181
|
*/
|
|
214
182
|
performance(options?: PerformanceOptions): Promise<PerformanceMetrics>;
|
|
215
183
|
/**
|
|
216
|
-
* Get statistical analysis for a commodity
|
|
184
|
+
* Get statistical analysis for a commodity.
|
|
217
185
|
*
|
|
218
|
-
*
|
|
219
|
-
* standard deviation, and distribution characteristics.
|
|
186
|
+
* Maps to `GET /v1/analytics/statistics`, which reads `code` and `period`.
|
|
220
187
|
*
|
|
221
|
-
* @param
|
|
222
|
-
* @param
|
|
188
|
+
* @param code - Commodity code to analyze (e.g. 'WTI_USD')
|
|
189
|
+
* @param period - Lookback window in days (default: 30)
|
|
223
190
|
* @returns Statistical analysis
|
|
224
191
|
*
|
|
225
|
-
* @throws {
|
|
226
|
-
* @throws {OilPriceAPIError} If API request fails
|
|
227
|
-
*
|
|
228
|
-
* @example
|
|
229
|
-
* ```typescript
|
|
230
|
-
* const stats = await client.analytics.statistics('BRENT_CRUDE_USD', 90);
|
|
231
|
-
* console.log(`Mean: $${stats.mean}`);
|
|
232
|
-
* console.log(`Std Dev: ${stats.std_dev}`);
|
|
233
|
-
* console.log(`Range: $${stats.min} - $${stats.max}`);
|
|
234
|
-
* ```
|
|
192
|
+
* @throws {ValidationError} If code is empty
|
|
235
193
|
*/
|
|
236
|
-
statistics(
|
|
194
|
+
statistics(code: string, period?: number): Promise<StatisticalAnalysis>;
|
|
237
195
|
/**
|
|
238
|
-
* Analyze correlation between two commodities
|
|
196
|
+
* Analyze correlation between two commodities.
|
|
239
197
|
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
198
|
+
* Maps to `GET /v1/analytics/correlation`, which reads `code1`, `code2`,
|
|
199
|
+
* `period` and optional `type`, `window`, `codes`.
|
|
242
200
|
*
|
|
243
|
-
* @param
|
|
244
|
-
* @param
|
|
245
|
-
* @param
|
|
201
|
+
* @param code1 - First commodity code
|
|
202
|
+
* @param code2 - Second commodity code
|
|
203
|
+
* @param options - Lookback window in days, or `{ period, type, window, codes }`
|
|
246
204
|
* @returns Correlation analysis
|
|
247
205
|
*
|
|
248
|
-
* @throws {
|
|
249
|
-
* @throws {OilPriceAPIError} If API request fails
|
|
206
|
+
* @throws {ValidationError} If either code is empty
|
|
250
207
|
*
|
|
251
208
|
* @example
|
|
252
209
|
* ```typescript
|
|
253
|
-
* const corr = await client.analytics.correlation('WTI_USD', 'BRENT_CRUDE_USD', 90);
|
|
254
|
-
* console.log(
|
|
255
|
-
* console.log(`Strength: ${corr.strength}`);
|
|
256
|
-
* console.log(`R-squared: ${corr.r_squared}`);
|
|
210
|
+
* const corr = await client.analytics.correlation('WTI_USD', 'BRENT_CRUDE_USD', { period: 90 });
|
|
211
|
+
* console.log(corr.correlation);
|
|
257
212
|
* ```
|
|
258
213
|
*/
|
|
259
|
-
correlation(
|
|
214
|
+
correlation(code1: string, code2: string, options?: number | CorrelationOptions): Promise<CorrelationAnalysis>;
|
|
260
215
|
/**
|
|
261
|
-
* Analyze price trend for a commodity
|
|
216
|
+
* Analyze price trend for a commodity.
|
|
262
217
|
*
|
|
263
|
-
*
|
|
218
|
+
* Maps to `GET /v1/analytics/trend`, which reads `code`, `period` and
|
|
219
|
+
* optional `type` ('analysis' | 'sma' | 'ema' | 'rsi' | 'levels') and `window`.
|
|
264
220
|
*
|
|
265
|
-
* @param
|
|
266
|
-
* @param
|
|
221
|
+
* @param code - Commodity code to analyze
|
|
222
|
+
* @param options - Lookback window in days, or `{ period, type, window }`
|
|
267
223
|
* @returns Trend analysis
|
|
268
224
|
*
|
|
269
|
-
* @throws {
|
|
270
|
-
* @throws {OilPriceAPIError} If API request fails
|
|
271
|
-
*
|
|
272
|
-
* @example
|
|
273
|
-
* ```typescript
|
|
274
|
-
* const trend = await client.analytics.trend('WTI_USD', 60);
|
|
275
|
-
* console.log(`Trend: ${trend.trend} (strength: ${trend.strength})`);
|
|
276
|
-
* console.log(`Support: $${trend.support}`);
|
|
277
|
-
* console.log(`Resistance: $${trend.resistance}`);
|
|
278
|
-
* ```
|
|
225
|
+
* @throws {ValidationError} If code is empty
|
|
279
226
|
*/
|
|
280
|
-
trend(
|
|
227
|
+
trend(code: string, options?: number | TrendOptions): Promise<TrendAnalysis>;
|
|
281
228
|
/**
|
|
282
|
-
* Analyze spread
|
|
283
|
-
*
|
|
284
|
-
* Calculates current spread and compares to historical patterns.
|
|
229
|
+
* Analyze a named commodity spread (basis / crack / ratio).
|
|
285
230
|
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
231
|
+
* Maps to `GET /v1/analytics/spread`, which reads `spread` (the named spread,
|
|
232
|
+
* e.g. 'wti_brent'), `period` and optional `type` ('current' | 'historical').
|
|
233
|
+
* Call with no `spread` to list the available named spreads.
|
|
289
234
|
*
|
|
290
|
-
* @
|
|
291
|
-
* @
|
|
235
|
+
* @param spread - Named spread (e.g. 'wti_brent'); omit to list available spreads
|
|
236
|
+
* @param options - Lookback window in days, or `{ period, type }`
|
|
237
|
+
* @returns Spread analysis (or the list of available spreads)
|
|
292
238
|
*
|
|
293
239
|
* @example
|
|
294
240
|
* ```typescript
|
|
295
|
-
* const spread = await client.analytics.spread('
|
|
296
|
-
* console.log(
|
|
297
|
-
* console.log(`Average spread: $${spread.average_spread}`);
|
|
298
|
-
* console.log(`Z-score: ${spread.z_score}`);
|
|
241
|
+
* const spread = await client.analytics.spread('wti_brent', { period: 30 });
|
|
242
|
+
* console.log(spread.current_spread);
|
|
299
243
|
* ```
|
|
300
244
|
*/
|
|
301
|
-
spread(
|
|
245
|
+
spread(spread?: string, options?: number | SpreadOptions): Promise<SpreadAnalysis>;
|
|
302
246
|
/**
|
|
303
|
-
* Get price forecast for a commodity
|
|
304
|
-
*
|
|
305
|
-
* Returns forecasted prices with confidence intervals.
|
|
306
|
-
*
|
|
307
|
-
* @param commodity - Commodity code to forecast
|
|
308
|
-
* @returns Price forecast
|
|
247
|
+
* Get a statistical price forecast for a commodity.
|
|
309
248
|
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
249
|
+
* Maps to `GET /v1/analytics/forecast`, which reads `code`, `method`
|
|
250
|
+
* (default 'ema') and `period` (default 90). Call with no `code` to list
|
|
251
|
+
* the available forecast methods.
|
|
312
252
|
*
|
|
313
|
-
* @
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
* console.log(`Forecast model: ${forecast.model}`);
|
|
317
|
-
* console.log(`Horizon: ${forecast.horizon_days} days`);
|
|
318
|
-
*
|
|
319
|
-
* forecast.forecast.forEach(point => {
|
|
320
|
-
* console.log(`${point.date}: $${point.price} (${point.lower_bound}-${point.upper_bound})`);
|
|
321
|
-
* });
|
|
322
|
-
* ```
|
|
253
|
+
* @param code - Commodity code to forecast; omit to list available methods
|
|
254
|
+
* @param options - `{ method, period }`
|
|
255
|
+
* @returns Price forecast (or the list of available methods)
|
|
323
256
|
*/
|
|
324
|
-
forecast(
|
|
257
|
+
forecast(code?: string, options?: ForecastOptions): Promise<PriceForecast>;
|
|
325
258
|
}
|