@qtsurfer/api-client 0.3.0 → 0.4.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 CHANGED
@@ -82,7 +82,7 @@ All operations are exported as standalone functions; every operation accepts an
82
82
  | `cancelExecution` | POST | `/backtesting/execute/{jobId}/cancel` | Cancel a running execution |
83
83
  | `getExecutionResult` | GET | `/backtesting/execute/{jobId}` | Poll or fetch execution results |
84
84
 
85
- All generated types (`Exchange`, `InstrumentDetail`, `BacktestJobResult`, `ResultMap`, etc.) are re-exported from the root.
85
+ All generated types (`Exchange`, `InstrumentDetail`, `BacktestJobResult`, `PrepareJobState`, `ResultMap`, etc.) are re-exported from the root.
86
86
 
87
87
  ## Configuring the client
88
88
 
package/dist/index.d.ts CHANGED
@@ -162,13 +162,13 @@ type JobState = {
162
162
  */
163
163
  contextId: string;
164
164
  /**
165
- * Current status of the job. `Partial` (prepare only) means some
166
- * hours are still being produced asynchronously — keep polling.
167
- * Treat `Completed | Aborted | Failed` as terminal; anything else
168
- * means keep polling.
165
+ * Current status of the job. Treat `Completed | Aborted | Failed` as
166
+ * terminal; `New | Started` mean keep polling. A single-instrument prepare
167
+ * is always terminal (`Completed`) decide from
168
+ * `PrepareJobState.coverageRatio`, not by polling.
169
169
  *
170
170
  */
171
- status: 'New' | 'Started' | 'Partial' | 'Completed' | 'Aborted' | 'Failed';
171
+ status: 'New' | 'Started' | 'Completed' | 'Aborted' | 'Failed';
172
172
  /**
173
173
  * Detailed status information, if available
174
174
  */
@@ -190,6 +190,61 @@ type JobState = {
190
190
  */
191
191
  endTime?: string | null;
192
192
  };
193
+ /**
194
+ * State of a single-instrument prepare job — the `JobState` shape plus a per-hour
195
+ * data-coverage summary. A single-instrument prepare is always terminal
196
+ * (`status: Completed`): the client decides what to do from `coverageRatio` (e.g.
197
+ * execute if it is at or above a chosen threshold) rather than polling for missing
198
+ * hours that may never arrive — a missing hour for one instrument usually means low
199
+ * activity, not missing data.
200
+ *
201
+ */
202
+ type PrepareJobState = JobState & {
203
+ /**
204
+ * Start of the available data range for the prepared instrument.
205
+ */
206
+ dataFrom?: string | null;
207
+ /**
208
+ * End of the available data range for the prepared instrument.
209
+ */
210
+ dataTo?: string | null;
211
+ /**
212
+ * `hoursWithData / totalHours` in `[0,1]` (`1.0` when `totalHours` is 0) — the
213
+ * fraction of hours in the requested range that have served data.
214
+ *
215
+ */
216
+ coverageRatio?: number;
217
+ /**
218
+ * Number of whole hours in the requested prepare range.
219
+ */
220
+ totalHours?: number;
221
+ /**
222
+ * Number of hours in the range that have data.
223
+ */
224
+ hoursWithData?: number;
225
+ /**
226
+ * One entry per hour in the range that has no data, with a rationale.
227
+ */
228
+ hoursWithoutData?: Array<{
229
+ /**
230
+ * The hour (UTC, hour-aligned) that has no data.
231
+ */
232
+ hour?: string;
233
+ /**
234
+ * Expected row count for the hour (currently always 0; reserved for
235
+ * future use). The rationale never depends on it.
236
+ *
237
+ */
238
+ expected?: number;
239
+ /**
240
+ * Why the hour has no data. `pending_conversion`: data for this hour is
241
+ * still being produced — a re-poll may fill it. `low_activity`: the
242
+ * instrument did not trade that hour. `unknown`: no data to classify by.
243
+ *
244
+ */
245
+ rationale?: 'pending_conversion' | 'low_activity' | 'unknown';
246
+ }>;
247
+ };
193
248
  /**
194
249
  * Response returned by async endpoints (`202 Accepted`). The `jobId` is deterministic for the
195
250
  * same input parameters — repeated calls with identical params return the same id.
@@ -728,7 +783,7 @@ type GetPreparationStatusResponses = {
728
783
  /**
729
784
  * Current prepare job state
730
785
  */
731
- 200: JobState;
786
+ 200: PrepareJobState;
732
787
  };
733
788
  type GetPreparationStatusResponse = GetPreparationStatusResponses[keyof GetPreparationStatusResponses];
734
789
  type ExecuteBacktestingData = {
@@ -988,7 +1043,7 @@ declare const prepareBacktesting: <ThrowOnError extends boolean = false>(options
988
1043
  * Poll until `status` is `Completed`, `Failed`, or `Aborted`.
989
1044
  *
990
1045
  */
991
- declare const getPreparationStatus: <ThrowOnError extends boolean = false>(options: Options<GetPreparationStatusData, ThrowOnError>) => _hey_api_client_fetch.RequestResult<JobState, ResponseError, ThrowOnError>;
1046
+ declare const getPreparationStatus: <ThrowOnError extends boolean = false>(options: Options<GetPreparationStatusData, ThrowOnError>) => _hey_api_client_fetch.RequestResult<PrepareJobState, ResponseError, ThrowOnError>;
992
1047
  /**
993
1048
  * Execute a compiled strategy against a prepared dataset
994
1049
  * Enqueues an execute task that runs the strategy identified by `strategyId` over the data
@@ -1025,4 +1080,4 @@ declare const getExecutionResult: <ThrowOnError extends boolean = false>(options
1025
1080
 
1026
1081
  declare const client: _hey_api_client_fetch.Client;
1027
1082
 
1028
- export { type AcceptedJob, type AuthData, type AuthError, type AuthErrors, type AuthResponse, type AuthResponses, type AuthTokenError, type AuthTokenResponse, type BacktestJobResult, type CancelExecutionData, type CancelExecutionError, type CancelExecutionErrors, type CancelExecutionResponse, type CancelExecutionResponses, type ClientOptions, type CoverageWindow, type DataSourceType, type EquityPoint, type Exchange, type ExecuteBacktestingData, type ExecuteBacktestingError, type ExecuteBacktestingErrors, type ExecuteBacktestingResponse, type ExecuteBacktestingResponses, type GetExchangeKlinesHourData, type GetExchangeKlinesHourError, type GetExchangeKlinesHourErrors, type GetExchangeKlinesHourResponse, type GetExchangeKlinesHourResponses, type GetExchangeTickersHourData, type GetExchangeTickersHourError, type GetExchangeTickersHourErrors, type GetExchangeTickersHourResponse, type GetExchangeTickersHourResponses, type GetExchangesData, type GetExchangesResponse, type GetExchangesResponses, type GetExecutionResultData, type GetExecutionResultError, type GetExecutionResultErrors, type GetExecutionResultResponse, type GetExecutionResultResponses, type GetInstrumentsData, type GetInstrumentsError, type GetInstrumentsErrors, type GetInstrumentsResponse, type GetInstrumentsResponses, type GetPreparationStatusData, type GetPreparationStatusError, type GetPreparationStatusErrors, type GetPreparationStatusResponse, type GetPreparationStatusResponses, type GetSegmentInstrumentsData, type GetSegmentInstrumentsError, type GetSegmentInstrumentsErrors, type GetSegmentInstrumentsResponse, type GetSegmentInstrumentsResponses, type GetStrategyStatusData, type GetStrategyStatusError, type GetStrategyStatusErrors, type GetStrategyStatusResponse, type GetStrategyStatusResponses, type HalLink, type Instrument, type InstrumentCoverage, type InstrumentDetail, type InstrumentLinks, type InstrumentListMeta, type InstrumentListResponse, type JobState, type Options, type PostStrategyData, type PostStrategyError, type PostStrategyErrors, type PostStrategyResponse, type PostStrategyResponses, type PrepareBacktestingData, type PrepareBacktestingError, type PrepareBacktestingErrors, type PrepareBacktestingResponse, type PrepareBacktestingResponses, type ResponseError, type ResultMap, type StrategyId, auth, cancelExecution, client, executeBacktesting, getExchangeKlinesHour, getExchangeTickersHour, getExchanges, getExecutionResult, getInstruments, getPreparationStatus, getSegmentInstruments, getStrategyStatus, postStrategy, prepareBacktesting };
1083
+ export { type AcceptedJob, type AuthData, type AuthError, type AuthErrors, type AuthResponse, type AuthResponses, type AuthTokenError, type AuthTokenResponse, type BacktestJobResult, type CancelExecutionData, type CancelExecutionError, type CancelExecutionErrors, type CancelExecutionResponse, type CancelExecutionResponses, type ClientOptions, type CoverageWindow, type DataSourceType, type EquityPoint, type Exchange, type ExecuteBacktestingData, type ExecuteBacktestingError, type ExecuteBacktestingErrors, type ExecuteBacktestingResponse, type ExecuteBacktestingResponses, type GetExchangeKlinesHourData, type GetExchangeKlinesHourError, type GetExchangeKlinesHourErrors, type GetExchangeKlinesHourResponse, type GetExchangeKlinesHourResponses, type GetExchangeTickersHourData, type GetExchangeTickersHourError, type GetExchangeTickersHourErrors, type GetExchangeTickersHourResponse, type GetExchangeTickersHourResponses, type GetExchangesData, type GetExchangesResponse, type GetExchangesResponses, type GetExecutionResultData, type GetExecutionResultError, type GetExecutionResultErrors, type GetExecutionResultResponse, type GetExecutionResultResponses, type GetInstrumentsData, type GetInstrumentsError, type GetInstrumentsErrors, type GetInstrumentsResponse, type GetInstrumentsResponses, type GetPreparationStatusData, type GetPreparationStatusError, type GetPreparationStatusErrors, type GetPreparationStatusResponse, type GetPreparationStatusResponses, type GetSegmentInstrumentsData, type GetSegmentInstrumentsError, type GetSegmentInstrumentsErrors, type GetSegmentInstrumentsResponse, type GetSegmentInstrumentsResponses, type GetStrategyStatusData, type GetStrategyStatusError, type GetStrategyStatusErrors, type GetStrategyStatusResponse, type GetStrategyStatusResponses, type HalLink, type Instrument, type InstrumentCoverage, type InstrumentDetail, type InstrumentLinks, type InstrumentListMeta, type InstrumentListResponse, type JobState, type Options, type PostStrategyData, type PostStrategyError, type PostStrategyErrors, type PostStrategyResponse, type PostStrategyResponses, type PrepareBacktestingData, type PrepareBacktestingError, type PrepareBacktestingErrors, type PrepareBacktestingResponse, type PrepareBacktestingResponses, type PrepareJobState, type ResponseError, type ResultMap, type StrategyId, auth, cancelExecution, client, executeBacktesting, getExchangeKlinesHour, getExchangeTickersHour, getExchanges, getExecutionResult, getInstruments, getPreparationStatus, getSegmentInstruments, getStrategyStatus, postStrategy, prepareBacktesting };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qtsurfer/api-client",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Auto-generated TypeScript API client for the QTSurfer API (from OpenAPI 3.1 spec)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -249,12 +249,12 @@ export const JobStateSchema = {
249
249
  },
250
250
  status: {
251
251
  type: 'string',
252
- description: `Current status of the job. \`Partial\` (prepare only) means some
253
- hours are still being produced asynchronously — keep polling.
254
- Treat \`Completed | Aborted | Failed\` as terminal; anything else
255
- means keep polling.
252
+ description: `Current status of the job. Treat \`Completed | Aborted | Failed\` as
253
+ terminal; \`New | Started\` mean keep polling. A single-instrument prepare
254
+ is always terminal (\`Completed\`) decide from
255
+ \`PrepareJobState.coverageRatio\`, not by polling.
256
256
  `,
257
- enum: ['New', 'Started', 'Partial', 'Completed', 'Aborted', 'Failed'],
257
+ enum: ['New', 'Started', 'Completed', 'Aborted', 'Failed'],
258
258
  example: 'Completed'
259
259
  },
260
260
  statusDetail: {
@@ -287,6 +287,89 @@ means keep polling.
287
287
  }
288
288
  } as const;
289
289
 
290
+ export const PrepareJobStateSchema = {
291
+ description: `State of a single-instrument prepare job — the \`JobState\` shape plus a per-hour
292
+ data-coverage summary. A single-instrument prepare is always terminal
293
+ (\`status: Completed\`): the client decides what to do from \`coverageRatio\` (e.g.
294
+ execute if it is at or above a chosen threshold) rather than polling for missing
295
+ hours that may never arrive — a missing hour for one instrument usually means low
296
+ activity, not missing data.
297
+ `,
298
+ allOf: [
299
+ {
300
+ '$ref': '#/components/schemas/JobState'
301
+ },
302
+ {
303
+ type: 'object',
304
+ properties: {
305
+ dataFrom: {
306
+ type: ['string', 'null'],
307
+ format: 'date-time',
308
+ description: 'Start of the available data range for the prepared instrument.',
309
+ example: '2026-04-14T13:00:00Z'
310
+ },
311
+ dataTo: {
312
+ type: ['string', 'null'],
313
+ format: 'date-time',
314
+ description: 'End of the available data range for the prepared instrument.',
315
+ example: '2026-04-14T15:30:05Z'
316
+ },
317
+ coverageRatio: {
318
+ type: 'number',
319
+ format: 'double',
320
+ minimum: 0,
321
+ maximum: 1,
322
+ description: `\`hoursWithData / totalHours\` in \`[0,1]\` (\`1.0\` when \`totalHours\` is 0) — the
323
+ fraction of hours in the requested range that have served data.
324
+ `,
325
+ example: 0.994
326
+ },
327
+ totalHours: {
328
+ type: 'integer',
329
+ description: 'Number of whole hours in the requested prepare range.',
330
+ example: 168
331
+ },
332
+ hoursWithData: {
333
+ type: 'integer',
334
+ description: 'Number of hours in the range that have data.',
335
+ example: 167
336
+ },
337
+ hoursWithoutData: {
338
+ type: 'array',
339
+ description: 'One entry per hour in the range that has no data, with a rationale.',
340
+ items: {
341
+ type: 'object',
342
+ properties: {
343
+ hour: {
344
+ type: 'string',
345
+ format: 'date-time',
346
+ description: 'The hour (UTC, hour-aligned) that has no data.',
347
+ example: '2026-04-14T02:00:00Z'
348
+ },
349
+ expected: {
350
+ type: 'integer',
351
+ description: `Expected row count for the hour (currently always 0; reserved for
352
+ future use). The rationale never depends on it.
353
+ `,
354
+ example: 0
355
+ },
356
+ rationale: {
357
+ type: 'string',
358
+ description: `Why the hour has no data. \`pending_conversion\`: data for this hour is
359
+ still being produced — a re-poll may fill it. \`low_activity\`: the
360
+ instrument did not trade that hour. \`unknown\`: no data to classify by.
361
+ `,
362
+ enum: ['pending_conversion', 'low_activity', 'unknown'],
363
+ example: 'low_activity'
364
+ }
365
+ }
366
+ }
367
+ }
368
+ }
369
+ }
370
+ ]
371
+ } as const;
372
+
290
373
  export const AcceptedJobSchema = {
291
374
  type: 'object',
292
375
  description: `Response returned by async endpoints (\`202 Accepted\`). The \`jobId\` is deterministic for the
@@ -172,13 +172,13 @@ export type JobState = {
172
172
  */
173
173
  contextId: string;
174
174
  /**
175
- * Current status of the job. `Partial` (prepare only) means some
176
- * hours are still being produced asynchronously — keep polling.
177
- * Treat `Completed | Aborted | Failed` as terminal; anything else
178
- * means keep polling.
175
+ * Current status of the job. Treat `Completed | Aborted | Failed` as
176
+ * terminal; `New | Started` mean keep polling. A single-instrument prepare
177
+ * is always terminal (`Completed`) decide from
178
+ * `PrepareJobState.coverageRatio`, not by polling.
179
179
  *
180
180
  */
181
- status: 'New' | 'Started' | 'Partial' | 'Completed' | 'Aborted' | 'Failed';
181
+ status: 'New' | 'Started' | 'Completed' | 'Aborted' | 'Failed';
182
182
  /**
183
183
  * Detailed status information, if available
184
184
  */
@@ -201,6 +201,62 @@ export type JobState = {
201
201
  endTime?: string | null;
202
202
  };
203
203
 
204
+ /**
205
+ * State of a single-instrument prepare job — the `JobState` shape plus a per-hour
206
+ * data-coverage summary. A single-instrument prepare is always terminal
207
+ * (`status: Completed`): the client decides what to do from `coverageRatio` (e.g.
208
+ * execute if it is at or above a chosen threshold) rather than polling for missing
209
+ * hours that may never arrive — a missing hour for one instrument usually means low
210
+ * activity, not missing data.
211
+ *
212
+ */
213
+ export type PrepareJobState = JobState & {
214
+ /**
215
+ * Start of the available data range for the prepared instrument.
216
+ */
217
+ dataFrom?: string | null;
218
+ /**
219
+ * End of the available data range for the prepared instrument.
220
+ */
221
+ dataTo?: string | null;
222
+ /**
223
+ * `hoursWithData / totalHours` in `[0,1]` (`1.0` when `totalHours` is 0) — the
224
+ * fraction of hours in the requested range that have served data.
225
+ *
226
+ */
227
+ coverageRatio?: number;
228
+ /**
229
+ * Number of whole hours in the requested prepare range.
230
+ */
231
+ totalHours?: number;
232
+ /**
233
+ * Number of hours in the range that have data.
234
+ */
235
+ hoursWithData?: number;
236
+ /**
237
+ * One entry per hour in the range that has no data, with a rationale.
238
+ */
239
+ hoursWithoutData?: Array<{
240
+ /**
241
+ * The hour (UTC, hour-aligned) that has no data.
242
+ */
243
+ hour?: string;
244
+ /**
245
+ * Expected row count for the hour (currently always 0; reserved for
246
+ * future use). The rationale never depends on it.
247
+ *
248
+ */
249
+ expected?: number;
250
+ /**
251
+ * Why the hour has no data. `pending_conversion`: data for this hour is
252
+ * still being produced — a re-poll may fill it. `low_activity`: the
253
+ * instrument did not trade that hour. `unknown`: no data to classify by.
254
+ *
255
+ */
256
+ rationale?: 'pending_conversion' | 'low_activity' | 'unknown';
257
+ }>;
258
+ };
259
+
204
260
  /**
205
261
  * Response returned by async endpoints (`202 Accepted`). The `jobId` is deterministic for the
206
262
  * same input parameters — repeated calls with identical params return the same id.
@@ -792,7 +848,7 @@ export type GetPreparationStatusResponses = {
792
848
  /**
793
849
  * Current prepare job state
794
850
  */
795
- 200: JobState;
851
+ 200: PrepareJobState;
796
852
  };
797
853
 
798
854
  export type GetPreparationStatusResponse = GetPreparationStatusResponses[keyof GetPreparationStatusResponses];