@qtsurfer/api-client 0.2.1 → 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
@@ -19,7 +19,65 @@ type ResponseError = {
19
19
  */
20
20
  type Instrument = string;
21
21
  /**
22
- * Exchange instrument with data availability and market info
22
+ * HAL-style response envelope for the instruments listing
23
+ */
24
+ type InstrumentListResponse = {
25
+ /**
26
+ * The list of instruments for the segment
27
+ */
28
+ data: Array<InstrumentDetail>;
29
+ meta: InstrumentListMeta;
30
+ _links: InstrumentLinks;
31
+ };
32
+ /**
33
+ * Metadata describing the instruments listing
34
+ */
35
+ type InstrumentListMeta = {
36
+ /**
37
+ * When this listing was last refreshed
38
+ */
39
+ updatedAt: string;
40
+ /**
41
+ * The exchange the instruments belong to
42
+ */
43
+ exchange: string;
44
+ /**
45
+ * The market segment served in `data`
46
+ */
47
+ segment: 'spot' | 'futures';
48
+ };
49
+ /**
50
+ * HAL `_links` — segment discovery for the instruments listing
51
+ */
52
+ type InstrumentLinks = {
53
+ /**
54
+ * Link to this listing
55
+ */
56
+ self: HalLink;
57
+ /**
58
+ * Link to the spot instruments listing. Present when the exchange has a spot segment.
59
+ */
60
+ spot?: HalLink;
61
+ /**
62
+ * Link to the futures instruments listing. Present only when the exchange has a futures segment.
63
+ */
64
+ futures?: HalLink;
65
+ };
66
+ /**
67
+ * A HAL link object (Hypertext Application Language)
68
+ */
69
+ type HalLink = {
70
+ /**
71
+ * The link target as an absolute-path URI reference (resolve against the API base). A URI Template (RFC 6570) when `templated` is true.
72
+ */
73
+ href: string;
74
+ /**
75
+ * True when `href` is an RFC 6570 URI Template.
76
+ */
77
+ templated?: boolean;
78
+ };
79
+ /**
80
+ * Exchange instrument with per-data-type coverage and market info
23
81
  */
24
82
  type InstrumentDetail = {
25
83
  /**
@@ -34,14 +92,7 @@ type InstrumentDetail = {
34
92
  * Quote currency
35
93
  */
36
94
  quote: string;
37
- /**
38
- * Earliest timestamp with quality-verified data available for backtesting
39
- */
40
- dataFrom?: string;
41
- /**
42
- * Latest timestamp with quality-verified data available for backtesting
43
- */
44
- dataTo?: string;
95
+ coverage?: InstrumentCoverage;
45
96
  /**
46
97
  * Last traded price
47
98
  */
@@ -51,6 +102,36 @@ type InstrumentDetail = {
51
102
  */
52
103
  volume24h?: number;
53
104
  };
105
+ /**
106
+ * Time coverage of available data for this instrument, per data type
107
+ */
108
+ type InstrumentCoverage = {
109
+ /**
110
+ * Coverage of ticker data
111
+ */
112
+ tickers?: CoverageWindow;
113
+ /**
114
+ * Coverage of kline (candlestick) data
115
+ */
116
+ klines?: CoverageWindow;
117
+ };
118
+ /**
119
+ * The time range of available data for a single data type
120
+ */
121
+ type CoverageWindow = {
122
+ /**
123
+ * Earliest timestamp with data available
124
+ */
125
+ from?: string;
126
+ /**
127
+ * Latest timestamp with data available
128
+ */
129
+ to?: string;
130
+ /**
131
+ * If the instrument stopped producing this data type (delisted/inactive), the timestamp it went inactive. Optional — omitted while the instrument is active.
132
+ */
133
+ inactiveSince?: string;
134
+ };
54
135
  /**
55
136
  * Exchange service provider
56
137
  */
@@ -81,13 +162,13 @@ type JobState = {
81
162
  */
82
163
  contextId: string;
83
164
  /**
84
- * Current status of the job. `Partial` (prepare only) means some
85
- * hours are still being produced asynchronously — keep polling.
86
- * Treat `Completed | Aborted | Failed` as terminal; anything else
87
- * 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.
88
169
  *
89
170
  */
90
- status: 'New' | 'Started' | 'Partial' | 'Completed' | 'Aborted' | 'Failed';
171
+ status: 'New' | 'Started' | 'Completed' | 'Aborted' | 'Failed';
91
172
  /**
92
173
  * Detailed status information, if available
93
174
  */
@@ -109,6 +190,61 @@ type JobState = {
109
190
  */
110
191
  endTime?: string | null;
111
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
+ };
112
248
  /**
113
249
  * Response returned by async endpoints (`202 Accepted`). The `jobId` is deterministic for the
114
250
  * same input parameters — repeated calls with identical params return the same id.
@@ -321,11 +457,40 @@ type GetInstrumentsErrors = {
321
457
  type GetInstrumentsError = GetInstrumentsErrors[keyof GetInstrumentsErrors];
322
458
  type GetInstrumentsResponses = {
323
459
  /**
324
- * A JSON array of Instrument details with data availability
460
+ * The default (spot) segment's instruments in `data`, `meta`, and HAL `_links` (self + spot/futures segment discovery)
325
461
  */
326
- 200: Array<InstrumentDetail>;
462
+ 200: InstrumentListResponse;
327
463
  };
328
464
  type GetInstrumentsResponse = GetInstrumentsResponses[keyof GetInstrumentsResponses];
465
+ type GetSegmentInstrumentsData = {
466
+ body?: never;
467
+ path: {
468
+ /**
469
+ * ID of the exchange to retrieve instruments for
470
+ */
471
+ exchangeId: string;
472
+ /**
473
+ * Market segment to list instruments for
474
+ */
475
+ segment: 'spot' | 'futures';
476
+ };
477
+ query?: never;
478
+ url: '/exchange/{exchangeId}/{segment}/instruments';
479
+ };
480
+ type GetSegmentInstrumentsErrors = {
481
+ /**
482
+ * Exchange, segment, or instrument catalog not found
483
+ */
484
+ 404: ResponseError;
485
+ };
486
+ type GetSegmentInstrumentsError = GetSegmentInstrumentsErrors[keyof GetSegmentInstrumentsErrors];
487
+ type GetSegmentInstrumentsResponses = {
488
+ /**
489
+ * An object with a `data` array of instrument details (each with per-data-type coverage) and a `meta` block
490
+ */
491
+ 200: InstrumentListResponse;
492
+ };
493
+ type GetSegmentInstrumentsResponse = GetSegmentInstrumentsResponses[keyof GetSegmentInstrumentsResponses];
329
494
  type GetExchangeTickersHourData = {
330
495
  body?: never;
331
496
  path: {
@@ -618,7 +783,7 @@ type GetPreparationStatusResponses = {
618
783
  /**
619
784
  * Current prepare job state
620
785
  */
621
- 200: JobState;
786
+ 200: PrepareJobState;
622
787
  };
623
788
  type GetPreparationStatusResponse = GetPreparationStatusResponses[keyof GetPreparationStatusResponses];
624
789
  type ExecuteBacktestingData = {
@@ -775,9 +940,23 @@ declare const auth: <ThrowOnError extends boolean = false>(options?: Options<Aut
775
940
  */
776
941
  declare const getExchanges: <ThrowOnError extends boolean = false>(options?: Options<GetExchangesData, ThrowOnError>) => _hey_api_client_fetch.RequestResult<Exchange[], unknown, ThrowOnError>;
777
942
  /**
778
- * Get a list of Instruments from a specific exchange
943
+ * Get an exchange's instruments (default spot segment)
944
+ * "Give me binance instruments" — returns the exchange's DEFAULT segment (`spot`)
945
+ * in `data`, each instrument with per-data-type coverage and market info. `meta`
946
+ * confirms the served `segment` (`spot`); HAL `_links` carry `self` plus the
947
+ * `spot` / `futures` segment-discovery links.
948
+ *
949
+ */
950
+ declare const getInstruments: <ThrowOnError extends boolean = false>(options: Options<GetInstrumentsData, ThrowOnError>) => _hey_api_client_fetch.RequestResult<InstrumentListResponse, ResponseError, ThrowOnError>;
951
+ /**
952
+ * Get the instruments for a specific exchange segment
953
+ * Returns the instruments for one market segment of the exchange, each with
954
+ * per-data-type coverage and market info. HAL `_links` carry `self` plus the
955
+ * `spot` / `futures` segment-discovery links; the default-segment shortcut is
956
+ * `GET /exchange/{exchangeId}/instruments` (spot).
957
+ *
779
958
  */
780
- declare const getInstruments: <ThrowOnError extends boolean = false>(options: Options<GetInstrumentsData, ThrowOnError>) => _hey_api_client_fetch.RequestResult<InstrumentDetail[], ResponseError, ThrowOnError>;
959
+ declare const getSegmentInstruments: <ThrowOnError extends boolean = false>(options: Options<GetSegmentInstrumentsData, ThrowOnError>) => _hey_api_client_fetch.RequestResult<InstrumentListResponse, ResponseError, ThrowOnError>;
781
960
  /**
782
961
  * Download one hour of tickers for an instrument as a Lastra segment
783
962
  * Serves exactly one hour of raw ticker data for the given instrument on the
@@ -864,7 +1043,7 @@ declare const prepareBacktesting: <ThrowOnError extends boolean = false>(options
864
1043
  * Poll until `status` is `Completed`, `Failed`, or `Aborted`.
865
1044
  *
866
1045
  */
867
- 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>;
868
1047
  /**
869
1048
  * Execute a compiled strategy against a prepared dataset
870
1049
  * Enqueues an execute task that runs the strategy identified by `strategyId` over the data
@@ -901,4 +1080,4 @@ declare const getExecutionResult: <ThrowOnError extends boolean = false>(options
901
1080
 
902
1081
  declare const client: _hey_api_client_fetch.Client;
903
1082
 
904
- 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 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 GetStrategyStatusData, type GetStrategyStatusError, type GetStrategyStatusErrors, type GetStrategyStatusResponse, type GetStrategyStatusResponses, type Instrument, type InstrumentDetail, 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, 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/dist/index.js CHANGED
@@ -29,6 +29,12 @@ var getInstruments = (options) => {
29
29
  ...options
30
30
  });
31
31
  };
32
+ var getSegmentInstruments = (options) => {
33
+ return (options.client ?? client).get({
34
+ url: "/exchange/{exchangeId}/{segment}/instruments",
35
+ ...options
36
+ });
37
+ };
32
38
  var getExchangeTickersHour = (options) => {
33
39
  return (options.client ?? client).get({
34
40
  url: "/exchange/{exchangeId}/tickers/{base}/{quote}",
@@ -149,6 +155,7 @@ export {
149
155
  getExecutionResult,
150
156
  getInstruments,
151
157
  getPreparationStatus,
158
+ getSegmentInstruments,
152
159
  getStrategyStatus,
153
160
  postStrategy,
154
161
  prepareBacktesting
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/generated/client.gen.ts","../src/generated/sdk.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ClientOptions } from './types.gen';\nimport { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;\n\nexport const client = createClient(createConfig<ClientOptions>({\n baseUrl: 'https://api.staging.qtsurfer.com/v1'\n}));","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';\nimport type { AuthData, AuthResponse, AuthError, GetExchangesData, GetExchangesResponse, GetInstrumentsData, GetInstrumentsResponse, GetInstrumentsError, GetExchangeTickersHourData, GetExchangeTickersHourResponse, GetExchangeTickersHourError, GetExchangeKlinesHourData, GetExchangeKlinesHourResponse, GetExchangeKlinesHourError, PostStrategyData, PostStrategyResponse, PostStrategyError, GetStrategyStatusData, GetStrategyStatusResponse, GetStrategyStatusError, PrepareBacktestingData, PrepareBacktestingResponse, PrepareBacktestingError, GetPreparationStatusData, GetPreparationStatusResponse, GetPreparationStatusError, ExecuteBacktestingData, ExecuteBacktestingResponse, ExecuteBacktestingError, CancelExecutionData, CancelExecutionResponse, CancelExecutionError, GetExecutionResultData, GetExecutionResultResponse, GetExecutionResultError } from './types.gen';\nimport { client as _heyApiClient } from './client.gen';\n\nexport type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * Exchange API key for a short-lived JWT\n * Exchanges a long-lived API key for a short-lived JWT used by every other\n * endpoint. This is the only endpoint that accepts an API key directly —\n * callers should obtain a JWT here, then send it as `Authorization: Bearer\n * <token>` to all other operations.\n *\n * The returned JWT carries the caller's subscription `tier` as a claim and\n * expires after `expires_in` seconds. Callers should refresh the token\n * before expiry (or on a `401` response) by calling this endpoint again.\n *\n */\nexport const auth = <ThrowOnError extends boolean = false>(options?: Options<AuthData, ThrowOnError>) => {\n return (options?.client ?? _heyApiClient).post<AuthResponse, AuthError, ThrowOnError>({\n security: [\n {\n name: 'X-API-Key',\n type: 'apiKey'\n }\n ],\n url: '/auth/token',\n ...options\n });\n};\n\n/**\n * Get a list of available exchanges\n */\nexport const getExchanges = <ThrowOnError extends boolean = false>(options?: Options<GetExchangesData, ThrowOnError>) => {\n return (options?.client ?? _heyApiClient).get<GetExchangesResponse, unknown, ThrowOnError>({\n url: '/exchanges',\n ...options\n });\n};\n\n/**\n * Get a list of Instruments from a specific exchange\n */\nexport const getInstruments = <ThrowOnError extends boolean = false>(options: Options<GetInstrumentsData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetInstrumentsResponse, GetInstrumentsError, ThrowOnError>({\n url: '/exchange/{exchangeId}/instruments',\n ...options\n });\n};\n\n/**\n * Download one hour of tickers for an instrument as a Lastra segment\n * Serves exactly one hour of raw ticker data for the given instrument on the\n * requested exchange. The payload is a native [Lastra](https://github.com/QTSurfer/lastra-java)\n * file — QTSurfer's columnar format for tick-precision timeseries — with\n * no JSON envelope.\n *\n * One segment = one hour, aligned to UTC. The `hour` query parameter selects\n * the segment and must match `YYYY-MM-DDTHH` (no minutes/seconds, no timezone\n * suffix). Example: `hour=2026-01-15T10` returns `h10.lastra` for\n * 2026-01-15, covering `[10:00:00Z, 11:00:00Z)`. Hours not yet available\n * return `404`.\n *\n * A `format=parquet` query parameter switches the response to on-the-fly\n * Parquet conversion via [lastra-convert](https://github.com/QTSurfer/lastra-convert)\n * for clients that don't yet read Lastra. Lastra is the primary format\n * and cheaper when the client can consume it.\n *\n * Clients:\n * - [lastra-java](https://github.com/QTSurfer/lastra-java) — reference\n * Java reader/writer with per-column codecs (ALP, Gorilla, delta-varint,\n * ZSTD) and CRC32 integrity.\n * - [lastra-ts](https://github.com/QTSurfer/lastra-ts) — TypeScript reader\n * (~4 kB bundle, browser + Node.js).\n * - [duckdb-lastra](https://github.com/QTSurfer/duckdb-lastra) — DuckDB\n * extension for ad-hoc SQL over Lastra files.\n * - [lastra-convert](https://github.com/QTSurfer/lastra-convert) — CLI + Java\n * API for converting to/from Parquet, Reef, and CSV.\n * - `curl -OJ` for offline dumps (the `Content-Disposition` header sets a\n * descriptive filename).\n *\n */\nexport const getExchangeTickersHour = <ThrowOnError extends boolean = false>(options: Options<GetExchangeTickersHourData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetExchangeTickersHourResponse, GetExchangeTickersHourError, ThrowOnError>({\n url: '/exchange/{exchangeId}/tickers/{base}/{quote}',\n ...options\n });\n};\n\n/**\n * Download one hour of klines for an instrument as a Lastra segment\n * Same shape and semantics as `/exchange/{exchangeId}/tickers/{base}/{quote}`,\n * but serves klines (aggregated bars) instead of raw ticks. One\n * [Lastra](https://github.com/QTSurfer/lastra-java) segment = one hour of\n * klines at the exchange's native kline cadence, aligned to UTC.\n *\n * Klines use the same columnar layout as tickers — readers that handle one\n * format read the other with the same code. Use this endpoint when a\n * per-tick payload would be too large for the window of interest.\n *\n */\nexport const getExchangeKlinesHour = <ThrowOnError extends boolean = false>(options: Options<GetExchangeKlinesHourData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetExchangeKlinesHourResponse, GetExchangeKlinesHourError, ThrowOnError>({\n url: '/exchange/{exchangeId}/klines/{base}/{quote}',\n ...options\n });\n};\n\n/**\n * Compile a strategy from source code\n * Submits raw strategy source for compilation. By default the call is synchronous and returns\n * the `strategyId` once compilation succeeds. Set the header `X-Compile-Async: true` to enqueue\n * the compile task and return immediately with a `jobId` — poll\n * `GET /strategy/{strategyId}` to check status.\n *\n * The `strategyId` is deterministic: the same source for the same user always produces the\n * same id.\n *\n */\nexport const postStrategy = <ThrowOnError extends boolean = false>(options: Options<PostStrategyData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).post<PostStrategyResponse, PostStrategyError, ThrowOnError>({\n bodySerializer: null,\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/strategy',\n ...options,\n headers: {\n 'Content-Type': 'text/plain',\n ...options?.headers\n }\n });\n};\n\n/**\n * Get the status of an async compile task\n * Polls the status of a strategy compilation. Useful when the strategy was submitted with\n * `X-Compile-Async: true`. Returns the resolved `strategyId` once compilation completes.\n *\n */\nexport const getStrategyStatus = <ThrowOnError extends boolean = false>(options: Options<GetStrategyStatusData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetStrategyStatusResponse, GetStrategyStatusError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/strategy/{strategyId}',\n ...options\n });\n};\n\n/**\n * Prepare backtesting data\n * Enqueues a prepare task over the requested date range. Returns immediately with a `jobId`;\n * poll `GET /backtest/{exchangeId}/{type}/prepare/{jobId}` for completion.\n *\n * The same params always return the same `jobId` (idempotent). Repeated calls with identical\n * params do not enqueue duplicate work — they reuse the existing job.\n *\n */\nexport const prepareBacktesting = <ThrowOnError extends boolean = false>(options: Options<PrepareBacktestingData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).post<PrepareBacktestingResponse, PrepareBacktestingError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/backtest/{exchangeId}/{type}/prepare',\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options?.headers\n }\n });\n};\n\n/**\n * Get the status of a prepare job\n * Retrieves the current state of the prepare job identified by `jobId`.\n * Poll until `status` is `Completed`, `Failed`, or `Aborted`.\n *\n */\nexport const getPreparationStatus = <ThrowOnError extends boolean = false>(options: Options<GetPreparationStatusData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetPreparationStatusResponse, GetPreparationStatusError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/backtest/{exchangeId}/{type}/prepare/{jobId}',\n ...options\n });\n};\n\n/**\n * Execute a compiled strategy against a prepared dataset\n * Enqueues an execute task that runs the strategy identified by `strategyId` over the data\n * prepared by the prepare job identified by `prepareJobId`. The instrument and date range are\n * recovered from the prepare job — they do not need to be sent again.\n *\n * Returns immediately with a `jobId`; poll `GET /backtest/{exchangeId}/{type}/execute/{jobId}`\n * for the result.\n *\n * The same params (same `prepareJobId`, `strategyId`, `storeSignals`) always return the same\n * `jobId` (idempotent).\n *\n */\nexport const executeBacktesting = <ThrowOnError extends boolean = false>(options: Options<ExecuteBacktestingData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).post<ExecuteBacktestingResponse, ExecuteBacktestingError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/backtest/{exchangeId}/{type}/execute',\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options?.headers\n }\n });\n};\n\n/**\n * Cancel a running backtest execution\n * Requests cancellation of the specified execution. The execution\n * status will transition to `Aborted` once the cancellation is\n * processed. Cancellation is asynchronous — poll the GET endpoint\n * to confirm the final status.\n *\n */\nexport const cancelExecution = <ThrowOnError extends boolean = false>(options: Options<CancelExecutionData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).delete<CancelExecutionResponse, CancelExecutionError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/backtest/{exchangeId}/{type}/execute/{jobId}',\n ...options\n });\n};\n\n/**\n * Get the result of a backtest execution job\n * Retrieves the current state and results of the execute job identified by `jobId`.\n * Poll until `state.status` is `Completed`, `Failed`, or `Aborted`.\n *\n */\nexport const getExecutionResult = <ThrowOnError extends boolean = false>(options: Options<GetExecutionResultData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetExecutionResultResponse, GetExecutionResultError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/backtest/{exchangeId}/{type}/execute/{jobId}',\n ...options\n });\n};"],"mappings":";AAGA,SAA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A,MACN;AAAA,QACI,QAAQ;AAAA,QACR,MAAM;AAAA,MACV;AAAA,IACJ;AAAA,IACA,KAAK;AAAA,IACL,GAAG;AAAA,EACP,CAAC;AACL;","names":[]}
1
+ {"version":3,"sources":["../src/generated/client.gen.ts","../src/generated/sdk.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ClientOptions } from './types.gen';\nimport { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;\n\nexport const client = createClient(createConfig<ClientOptions>({\n baseUrl: 'https://api.staging.qtsurfer.com/v1'\n}));","// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';\nimport type { AuthData, AuthResponse, AuthError, GetExchangesData, GetExchangesResponse, GetInstrumentsData, GetInstrumentsResponse, GetInstrumentsError, GetSegmentInstrumentsData, GetSegmentInstrumentsResponse, GetSegmentInstrumentsError, GetExchangeTickersHourData, GetExchangeTickersHourResponse, GetExchangeTickersHourError, GetExchangeKlinesHourData, GetExchangeKlinesHourResponse, GetExchangeKlinesHourError, PostStrategyData, PostStrategyResponse, PostStrategyError, GetStrategyStatusData, GetStrategyStatusResponse, GetStrategyStatusError, PrepareBacktestingData, PrepareBacktestingResponse, PrepareBacktestingError, GetPreparationStatusData, GetPreparationStatusResponse, GetPreparationStatusError, ExecuteBacktestingData, ExecuteBacktestingResponse, ExecuteBacktestingError, CancelExecutionData, CancelExecutionResponse, CancelExecutionError, GetExecutionResultData, GetExecutionResultResponse, GetExecutionResultError } from './types.gen';\nimport { client as _heyApiClient } from './client.gen';\n\nexport type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {\n /**\n * You can provide a client instance returned by `createClient()` instead of\n * individual options. This might be also useful if you want to implement a\n * custom client.\n */\n client?: Client;\n /**\n * You can pass arbitrary values through the `meta` object. This can be\n * used to access values that aren't defined as part of the SDK function.\n */\n meta?: Record<string, unknown>;\n};\n\n/**\n * Exchange API key for a short-lived JWT\n * Exchanges a long-lived API key for a short-lived JWT used by every other\n * endpoint. This is the only endpoint that accepts an API key directly —\n * callers should obtain a JWT here, then send it as `Authorization: Bearer\n * <token>` to all other operations.\n *\n * The returned JWT carries the caller's subscription `tier` as a claim and\n * expires after `expires_in` seconds. Callers should refresh the token\n * before expiry (or on a `401` response) by calling this endpoint again.\n *\n */\nexport const auth = <ThrowOnError extends boolean = false>(options?: Options<AuthData, ThrowOnError>) => {\n return (options?.client ?? _heyApiClient).post<AuthResponse, AuthError, ThrowOnError>({\n security: [\n {\n name: 'X-API-Key',\n type: 'apiKey'\n }\n ],\n url: '/auth/token',\n ...options\n });\n};\n\n/**\n * Get a list of available exchanges\n */\nexport const getExchanges = <ThrowOnError extends boolean = false>(options?: Options<GetExchangesData, ThrowOnError>) => {\n return (options?.client ?? _heyApiClient).get<GetExchangesResponse, unknown, ThrowOnError>({\n url: '/exchanges',\n ...options\n });\n};\n\n/**\n * Get an exchange's instruments (default spot segment)\n * \"Give me binance instruments\" — returns the exchange's DEFAULT segment (`spot`)\n * in `data`, each instrument with per-data-type coverage and market info. `meta`\n * confirms the served `segment` (`spot`); HAL `_links` carry `self` plus the\n * `spot` / `futures` segment-discovery links.\n *\n */\nexport const getInstruments = <ThrowOnError extends boolean = false>(options: Options<GetInstrumentsData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetInstrumentsResponse, GetInstrumentsError, ThrowOnError>({\n url: '/exchange/{exchangeId}/instruments',\n ...options\n });\n};\n\n/**\n * Get the instruments for a specific exchange segment\n * Returns the instruments for one market segment of the exchange, each with\n * per-data-type coverage and market info. HAL `_links` carry `self` plus the\n * `spot` / `futures` segment-discovery links; the default-segment shortcut is\n * `GET /exchange/{exchangeId}/instruments` (spot).\n *\n */\nexport const getSegmentInstruments = <ThrowOnError extends boolean = false>(options: Options<GetSegmentInstrumentsData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetSegmentInstrumentsResponse, GetSegmentInstrumentsError, ThrowOnError>({\n url: '/exchange/{exchangeId}/{segment}/instruments',\n ...options\n });\n};\n\n/**\n * Download one hour of tickers for an instrument as a Lastra segment\n * Serves exactly one hour of raw ticker data for the given instrument on the\n * requested exchange. The payload is a native [Lastra](https://github.com/QTSurfer/lastra-java)\n * file — QTSurfer's columnar format for tick-precision timeseries — with\n * no JSON envelope.\n *\n * One segment = one hour, aligned to UTC. The `hour` query parameter selects\n * the segment and must match `YYYY-MM-DDTHH` (no minutes/seconds, no timezone\n * suffix). Example: `hour=2026-01-15T10` returns `h10.lastra` for\n * 2026-01-15, covering `[10:00:00Z, 11:00:00Z)`. Hours not yet available\n * return `404`.\n *\n * A `format=parquet` query parameter switches the response to on-the-fly\n * Parquet conversion via [lastra-convert](https://github.com/QTSurfer/lastra-convert)\n * for clients that don't yet read Lastra. Lastra is the primary format\n * and cheaper when the client can consume it.\n *\n * Clients:\n * - [lastra-java](https://github.com/QTSurfer/lastra-java) — reference\n * Java reader/writer with per-column codecs (ALP, Gorilla, delta-varint,\n * ZSTD) and CRC32 integrity.\n * - [lastra-ts](https://github.com/QTSurfer/lastra-ts) — TypeScript reader\n * (~4 kB bundle, browser + Node.js).\n * - [duckdb-lastra](https://github.com/QTSurfer/duckdb-lastra) — DuckDB\n * extension for ad-hoc SQL over Lastra files.\n * - [lastra-convert](https://github.com/QTSurfer/lastra-convert) — CLI + Java\n * API for converting to/from Parquet, Reef, and CSV.\n * - `curl -OJ` for offline dumps (the `Content-Disposition` header sets a\n * descriptive filename).\n *\n */\nexport const getExchangeTickersHour = <ThrowOnError extends boolean = false>(options: Options<GetExchangeTickersHourData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetExchangeTickersHourResponse, GetExchangeTickersHourError, ThrowOnError>({\n url: '/exchange/{exchangeId}/tickers/{base}/{quote}',\n ...options\n });\n};\n\n/**\n * Download one hour of klines for an instrument as a Lastra segment\n * Same shape and semantics as `/exchange/{exchangeId}/tickers/{base}/{quote}`,\n * but serves klines (aggregated bars) instead of raw ticks. One\n * [Lastra](https://github.com/QTSurfer/lastra-java) segment = one hour of\n * klines at the exchange's native kline cadence, aligned to UTC.\n *\n * Klines use the same columnar layout as tickers — readers that handle one\n * format read the other with the same code. Use this endpoint when a\n * per-tick payload would be too large for the window of interest.\n *\n */\nexport const getExchangeKlinesHour = <ThrowOnError extends boolean = false>(options: Options<GetExchangeKlinesHourData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetExchangeKlinesHourResponse, GetExchangeKlinesHourError, ThrowOnError>({\n url: '/exchange/{exchangeId}/klines/{base}/{quote}',\n ...options\n });\n};\n\n/**\n * Compile a strategy from source code\n * Submits raw strategy source for compilation. By default the call is synchronous and returns\n * the `strategyId` once compilation succeeds. Set the header `X-Compile-Async: true` to enqueue\n * the compile task and return immediately with a `jobId` — poll\n * `GET /strategy/{strategyId}` to check status.\n *\n * The `strategyId` is deterministic: the same source for the same user always produces the\n * same id.\n *\n */\nexport const postStrategy = <ThrowOnError extends boolean = false>(options: Options<PostStrategyData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).post<PostStrategyResponse, PostStrategyError, ThrowOnError>({\n bodySerializer: null,\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/strategy',\n ...options,\n headers: {\n 'Content-Type': 'text/plain',\n ...options?.headers\n }\n });\n};\n\n/**\n * Get the status of an async compile task\n * Polls the status of a strategy compilation. Useful when the strategy was submitted with\n * `X-Compile-Async: true`. Returns the resolved `strategyId` once compilation completes.\n *\n */\nexport const getStrategyStatus = <ThrowOnError extends boolean = false>(options: Options<GetStrategyStatusData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetStrategyStatusResponse, GetStrategyStatusError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/strategy/{strategyId}',\n ...options\n });\n};\n\n/**\n * Prepare backtesting data\n * Enqueues a prepare task over the requested date range. Returns immediately with a `jobId`;\n * poll `GET /backtest/{exchangeId}/{type}/prepare/{jobId}` for completion.\n *\n * The same params always return the same `jobId` (idempotent). Repeated calls with identical\n * params do not enqueue duplicate work — they reuse the existing job.\n *\n */\nexport const prepareBacktesting = <ThrowOnError extends boolean = false>(options: Options<PrepareBacktestingData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).post<PrepareBacktestingResponse, PrepareBacktestingError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/backtest/{exchangeId}/{type}/prepare',\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options?.headers\n }\n });\n};\n\n/**\n * Get the status of a prepare job\n * Retrieves the current state of the prepare job identified by `jobId`.\n * Poll until `status` is `Completed`, `Failed`, or `Aborted`.\n *\n */\nexport const getPreparationStatus = <ThrowOnError extends boolean = false>(options: Options<GetPreparationStatusData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetPreparationStatusResponse, GetPreparationStatusError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/backtest/{exchangeId}/{type}/prepare/{jobId}',\n ...options\n });\n};\n\n/**\n * Execute a compiled strategy against a prepared dataset\n * Enqueues an execute task that runs the strategy identified by `strategyId` over the data\n * prepared by the prepare job identified by `prepareJobId`. The instrument and date range are\n * recovered from the prepare job — they do not need to be sent again.\n *\n * Returns immediately with a `jobId`; poll `GET /backtest/{exchangeId}/{type}/execute/{jobId}`\n * for the result.\n *\n * The same params (same `prepareJobId`, `strategyId`, `storeSignals`) always return the same\n * `jobId` (idempotent).\n *\n */\nexport const executeBacktesting = <ThrowOnError extends boolean = false>(options: Options<ExecuteBacktestingData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).post<ExecuteBacktestingResponse, ExecuteBacktestingError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/backtest/{exchangeId}/{type}/execute',\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...options?.headers\n }\n });\n};\n\n/**\n * Cancel a running backtest execution\n * Requests cancellation of the specified execution. The execution\n * status will transition to `Aborted` once the cancellation is\n * processed. Cancellation is asynchronous — poll the GET endpoint\n * to confirm the final status.\n *\n */\nexport const cancelExecution = <ThrowOnError extends boolean = false>(options: Options<CancelExecutionData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).delete<CancelExecutionResponse, CancelExecutionError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/backtest/{exchangeId}/{type}/execute/{jobId}',\n ...options\n });\n};\n\n/**\n * Get the result of a backtest execution job\n * Retrieves the current state and results of the execute job identified by `jobId`.\n * Poll until `state.status` is `Completed`, `Failed`, or `Aborted`.\n *\n */\nexport const getExecutionResult = <ThrowOnError extends boolean = false>(options: Options<GetExecutionResultData, ThrowOnError>) => {\n return (options.client ?? _heyApiClient).get<GetExecutionResultResponse, GetExecutionResultError, ThrowOnError>({\n security: [\n {\n scheme: 'bearer',\n type: 'http'\n }\n ],\n url: '/backtest/{exchangeId}/{type}/execute/{jobId}',\n ...options\n });\n};"],"mappings":";AAGA,SAAkE,cAAc,oBAAoB;AAY7F,IAAM,SAAS,aAAa,aAA4B;AAAA,EAC3D,SAAS;AACb,CAAC,CAAC;;;ACeK,IAAM,OAAO,CAAuC,YAA8C;AACrG,UAAQ,SAAS,UAAU,QAAe,KAA4C;AAAA,IAClF,UAAU;AAAA,MACN;AAAA,QACI,MAAM;AAAA,QACN,MAAM;AAAA,MACV;AAAA,IACJ;AAAA,IACA,KAAK;AAAA,IACL,GAA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-1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qtsurfer/api-client",
3
- "version": "0.2.1",
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",
@@ -24,8 +24,105 @@ export const InstrumentSchema = {
24
24
  example: 'BTC/USDT'
25
25
  } as const;
26
26
 
27
+ export const InstrumentListResponseSchema = {
28
+ description: 'HAL-style response envelope for the instruments listing',
29
+ type: 'object',
30
+ required: ['data', 'meta', '_links'],
31
+ properties: {
32
+ data: {
33
+ type: 'array',
34
+ description: 'The list of instruments for the segment',
35
+ items: {
36
+ '$ref': '#/components/schemas/InstrumentDetail'
37
+ }
38
+ },
39
+ meta: {
40
+ '$ref': '#/components/schemas/InstrumentListMeta'
41
+ },
42
+ _links: {
43
+ '$ref': '#/components/schemas/InstrumentLinks'
44
+ }
45
+ }
46
+ } as const;
47
+
48
+ export const InstrumentListMetaSchema = {
49
+ description: 'Metadata describing the instruments listing',
50
+ type: 'object',
51
+ required: ['updatedAt', 'exchange', 'segment'],
52
+ properties: {
53
+ updatedAt: {
54
+ type: 'string',
55
+ format: 'date-time',
56
+ description: 'When this listing was last refreshed',
57
+ example: '2026-07-09T19:09:07Z'
58
+ },
59
+ exchange: {
60
+ type: 'string',
61
+ description: 'The exchange the instruments belong to',
62
+ example: 'binance'
63
+ },
64
+ segment: {
65
+ type: 'string',
66
+ enum: ['spot', 'futures'],
67
+ description: 'The market segment served in `data`',
68
+ example: 'spot'
69
+ }
70
+ }
71
+ } as const;
72
+
73
+ export const InstrumentLinksSchema = {
74
+ description: 'HAL `_links` — segment discovery for the instruments listing',
75
+ type: 'object',
76
+ required: ['self'],
77
+ properties: {
78
+ self: {
79
+ allOf: [
80
+ {
81
+ '$ref': '#/components/schemas/HalLink'
82
+ }
83
+ ],
84
+ description: 'Link to this listing'
85
+ },
86
+ spot: {
87
+ allOf: [
88
+ {
89
+ '$ref': '#/components/schemas/HalLink'
90
+ }
91
+ ],
92
+ description: 'Link to the spot instruments listing. Present when the exchange has a spot segment.'
93
+ },
94
+ futures: {
95
+ allOf: [
96
+ {
97
+ '$ref': '#/components/schemas/HalLink'
98
+ }
99
+ ],
100
+ description: 'Link to the futures instruments listing. Present only when the exchange has a futures segment.'
101
+ }
102
+ }
103
+ } as const;
104
+
105
+ export const HalLinkSchema = {
106
+ description: 'A HAL link object (Hypertext Application Language)',
107
+ type: 'object',
108
+ required: ['href'],
109
+ properties: {
110
+ href: {
111
+ type: 'string',
112
+ format: 'uri-reference',
113
+ description: 'The link target as an absolute-path URI reference (resolve against the API base). A URI Template (RFC 6570) when `templated` is true.',
114
+ example: '/v1/exchange/binance/spot/instruments'
115
+ },
116
+ templated: {
117
+ type: 'boolean',
118
+ description: 'True when `href` is an RFC 6570 URI Template.',
119
+ example: false
120
+ }
121
+ }
122
+ } as const;
123
+
27
124
  export const InstrumentDetailSchema = {
28
- description: 'Exchange instrument with data availability and market info',
125
+ description: 'Exchange instrument with per-data-type coverage and market info',
29
126
  type: 'object',
30
127
  required: ['id', 'base', 'quote'],
31
128
  properties: {
@@ -44,17 +141,8 @@ export const InstrumentDetailSchema = {
44
141
  description: 'Quote currency',
45
142
  example: 'USDT'
46
143
  },
47
- dataFrom: {
48
- type: 'string',
49
- format: 'date-time',
50
- description: 'Earliest timestamp with quality-verified data available for backtesting',
51
- example: '2026-03-17T00:00:00Z'
52
- },
53
- dataTo: {
54
- type: 'string',
55
- format: 'date-time',
56
- description: 'Latest timestamp with quality-verified data available for backtesting',
57
- example: '2026-03-31T18:00:00Z'
144
+ coverage: {
145
+ '$ref': '#/components/schemas/InstrumentCoverage'
58
146
  },
59
147
  lastPrice: {
60
148
  type: 'number',
@@ -71,6 +159,54 @@ export const InstrumentDetailSchema = {
71
159
  }
72
160
  } as const;
73
161
 
162
+ export const InstrumentCoverageSchema = {
163
+ description: 'Time coverage of available data for this instrument, per data type',
164
+ type: 'object',
165
+ properties: {
166
+ tickers: {
167
+ allOf: [
168
+ {
169
+ '$ref': '#/components/schemas/CoverageWindow'
170
+ }
171
+ ],
172
+ description: 'Coverage of ticker data'
173
+ },
174
+ klines: {
175
+ allOf: [
176
+ {
177
+ '$ref': '#/components/schemas/CoverageWindow'
178
+ }
179
+ ],
180
+ description: 'Coverage of kline (candlestick) data'
181
+ }
182
+ }
183
+ } as const;
184
+
185
+ export const CoverageWindowSchema = {
186
+ description: 'The time range of available data for a single data type',
187
+ type: 'object',
188
+ properties: {
189
+ from: {
190
+ type: 'string',
191
+ format: 'date-time',
192
+ description: 'Earliest timestamp with data available',
193
+ example: '2026-04-10T21:00:00Z'
194
+ },
195
+ to: {
196
+ type: 'string',
197
+ format: 'date-time',
198
+ description: 'Latest timestamp with data available',
199
+ example: '2026-07-09T20:31:08Z'
200
+ },
201
+ inactiveSince: {
202
+ type: 'string',
203
+ format: 'date-time',
204
+ description: 'If the instrument stopped producing this data type (delisted/inactive), the timestamp it went inactive. Optional — omitted while the instrument is active.',
205
+ example: '2026-06-30T12:00:00Z'
206
+ }
207
+ }
208
+ } as const;
209
+
74
210
  export const ExchangeSchema = {
75
211
  description: 'Exchange service provider',
76
212
  type: 'object',
@@ -113,12 +249,12 @@ export const JobStateSchema = {
113
249
  },
114
250
  status: {
115
251
  type: 'string',
116
- description: `Current status of the job. \`Partial\` (prepare only) means some
117
- hours are still being produced asynchronously — keep polling.
118
- Treat \`Completed | Aborted | Failed\` as terminal; anything else
119
- 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.
120
256
  `,
121
- enum: ['New', 'Started', 'Partial', 'Completed', 'Aborted', 'Failed'],
257
+ enum: ['New', 'Started', 'Completed', 'Aborted', 'Failed'],
122
258
  example: 'Completed'
123
259
  },
124
260
  statusDetail: {
@@ -151,6 +287,89 @@ means keep polling.
151
287
  }
152
288
  } as const;
153
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
+
154
373
  export const AcceptedJobSchema = {
155
374
  type: 'object',
156
375
  description: `Response returned by async endpoints (\`202 Accepted\`). The \`jobId\` is deterministic for the
@@ -1,7 +1,7 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
2
 
3
3
  import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
4
- import type { AuthData, AuthResponse, AuthError, GetExchangesData, GetExchangesResponse, GetInstrumentsData, GetInstrumentsResponse, GetInstrumentsError, GetExchangeTickersHourData, GetExchangeTickersHourResponse, GetExchangeTickersHourError, GetExchangeKlinesHourData, GetExchangeKlinesHourResponse, GetExchangeKlinesHourError, PostStrategyData, PostStrategyResponse, PostStrategyError, GetStrategyStatusData, GetStrategyStatusResponse, GetStrategyStatusError, PrepareBacktestingData, PrepareBacktestingResponse, PrepareBacktestingError, GetPreparationStatusData, GetPreparationStatusResponse, GetPreparationStatusError, ExecuteBacktestingData, ExecuteBacktestingResponse, ExecuteBacktestingError, CancelExecutionData, CancelExecutionResponse, CancelExecutionError, GetExecutionResultData, GetExecutionResultResponse, GetExecutionResultError } from './types.gen';
4
+ import type { AuthData, AuthResponse, AuthError, GetExchangesData, GetExchangesResponse, GetInstrumentsData, GetInstrumentsResponse, GetInstrumentsError, GetSegmentInstrumentsData, GetSegmentInstrumentsResponse, GetSegmentInstrumentsError, GetExchangeTickersHourData, GetExchangeTickersHourResponse, GetExchangeTickersHourError, GetExchangeKlinesHourData, GetExchangeKlinesHourResponse, GetExchangeKlinesHourError, PostStrategyData, PostStrategyResponse, PostStrategyError, GetStrategyStatusData, GetStrategyStatusResponse, GetStrategyStatusError, PrepareBacktestingData, PrepareBacktestingResponse, PrepareBacktestingError, GetPreparationStatusData, GetPreparationStatusResponse, GetPreparationStatusError, ExecuteBacktestingData, ExecuteBacktestingResponse, ExecuteBacktestingError, CancelExecutionData, CancelExecutionResponse, CancelExecutionError, GetExecutionResultData, GetExecutionResultResponse, GetExecutionResultError } from './types.gen';
5
5
  import { client as _heyApiClient } from './client.gen';
6
6
 
7
7
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
@@ -54,7 +54,12 @@ export const getExchanges = <ThrowOnError extends boolean = false>(options?: Opt
54
54
  };
55
55
 
56
56
  /**
57
- * Get a list of Instruments from a specific exchange
57
+ * Get an exchange's instruments (default spot segment)
58
+ * "Give me binance instruments" — returns the exchange's DEFAULT segment (`spot`)
59
+ * in `data`, each instrument with per-data-type coverage and market info. `meta`
60
+ * confirms the served `segment` (`spot`); HAL `_links` carry `self` plus the
61
+ * `spot` / `futures` segment-discovery links.
62
+ *
58
63
  */
59
64
  export const getInstruments = <ThrowOnError extends boolean = false>(options: Options<GetInstrumentsData, ThrowOnError>) => {
60
65
  return (options.client ?? _heyApiClient).get<GetInstrumentsResponse, GetInstrumentsError, ThrowOnError>({
@@ -63,6 +68,21 @@ export const getInstruments = <ThrowOnError extends boolean = false>(options: Op
63
68
  });
64
69
  };
65
70
 
71
+ /**
72
+ * Get the instruments for a specific exchange segment
73
+ * Returns the instruments for one market segment of the exchange, each with
74
+ * per-data-type coverage and market info. HAL `_links` carry `self` plus the
75
+ * `spot` / `futures` segment-discovery links; the default-segment shortcut is
76
+ * `GET /exchange/{exchangeId}/instruments` (spot).
77
+ *
78
+ */
79
+ export const getSegmentInstruments = <ThrowOnError extends boolean = false>(options: Options<GetSegmentInstrumentsData, ThrowOnError>) => {
80
+ return (options.client ?? _heyApiClient).get<GetSegmentInstrumentsResponse, GetSegmentInstrumentsError, ThrowOnError>({
81
+ url: '/exchange/{exchangeId}/{segment}/instruments',
82
+ ...options
83
+ });
84
+ };
85
+
66
86
  /**
67
87
  * Download one hour of tickers for an instrument as a Lastra segment
68
88
  * Serves exactly one hour of raw ticker data for the given instrument on the
@@ -20,7 +20,69 @@ export type ResponseError = {
20
20
  export type Instrument = string;
21
21
 
22
22
  /**
23
- * Exchange instrument with data availability and market info
23
+ * HAL-style response envelope for the instruments listing
24
+ */
25
+ export type InstrumentListResponse = {
26
+ /**
27
+ * The list of instruments for the segment
28
+ */
29
+ data: Array<InstrumentDetail>;
30
+ meta: InstrumentListMeta;
31
+ _links: InstrumentLinks;
32
+ };
33
+
34
+ /**
35
+ * Metadata describing the instruments listing
36
+ */
37
+ export type InstrumentListMeta = {
38
+ /**
39
+ * When this listing was last refreshed
40
+ */
41
+ updatedAt: string;
42
+ /**
43
+ * The exchange the instruments belong to
44
+ */
45
+ exchange: string;
46
+ /**
47
+ * The market segment served in `data`
48
+ */
49
+ segment: 'spot' | 'futures';
50
+ };
51
+
52
+ /**
53
+ * HAL `_links` — segment discovery for the instruments listing
54
+ */
55
+ export type InstrumentLinks = {
56
+ /**
57
+ * Link to this listing
58
+ */
59
+ self: HalLink;
60
+ /**
61
+ * Link to the spot instruments listing. Present when the exchange has a spot segment.
62
+ */
63
+ spot?: HalLink;
64
+ /**
65
+ * Link to the futures instruments listing. Present only when the exchange has a futures segment.
66
+ */
67
+ futures?: HalLink;
68
+ };
69
+
70
+ /**
71
+ * A HAL link object (Hypertext Application Language)
72
+ */
73
+ export type HalLink = {
74
+ /**
75
+ * The link target as an absolute-path URI reference (resolve against the API base). A URI Template (RFC 6570) when `templated` is true.
76
+ */
77
+ href: string;
78
+ /**
79
+ * True when `href` is an RFC 6570 URI Template.
80
+ */
81
+ templated?: boolean;
82
+ };
83
+
84
+ /**
85
+ * Exchange instrument with per-data-type coverage and market info
24
86
  */
25
87
  export type InstrumentDetail = {
26
88
  /**
@@ -35,14 +97,7 @@ export type InstrumentDetail = {
35
97
  * Quote currency
36
98
  */
37
99
  quote: string;
38
- /**
39
- * Earliest timestamp with quality-verified data available for backtesting
40
- */
41
- dataFrom?: string;
42
- /**
43
- * Latest timestamp with quality-verified data available for backtesting
44
- */
45
- dataTo?: string;
100
+ coverage?: InstrumentCoverage;
46
101
  /**
47
102
  * Last traded price
48
103
  */
@@ -53,6 +108,38 @@ export type InstrumentDetail = {
53
108
  volume24h?: number;
54
109
  };
55
110
 
111
+ /**
112
+ * Time coverage of available data for this instrument, per data type
113
+ */
114
+ export type InstrumentCoverage = {
115
+ /**
116
+ * Coverage of ticker data
117
+ */
118
+ tickers?: CoverageWindow;
119
+ /**
120
+ * Coverage of kline (candlestick) data
121
+ */
122
+ klines?: CoverageWindow;
123
+ };
124
+
125
+ /**
126
+ * The time range of available data for a single data type
127
+ */
128
+ export type CoverageWindow = {
129
+ /**
130
+ * Earliest timestamp with data available
131
+ */
132
+ from?: string;
133
+ /**
134
+ * Latest timestamp with data available
135
+ */
136
+ to?: string;
137
+ /**
138
+ * If the instrument stopped producing this data type (delisted/inactive), the timestamp it went inactive. Optional — omitted while the instrument is active.
139
+ */
140
+ inactiveSince?: string;
141
+ };
142
+
56
143
  /**
57
144
  * Exchange service provider
58
145
  */
@@ -85,13 +172,13 @@ export type JobState = {
85
172
  */
86
173
  contextId: string;
87
174
  /**
88
- * Current status of the job. `Partial` (prepare only) means some
89
- * hours are still being produced asynchronously — keep polling.
90
- * Treat `Completed | Aborted | Failed` as terminal; anything else
91
- * 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.
92
179
  *
93
180
  */
94
- status: 'New' | 'Started' | 'Partial' | 'Completed' | 'Aborted' | 'Failed';
181
+ status: 'New' | 'Started' | 'Completed' | 'Aborted' | 'Failed';
95
182
  /**
96
183
  * Detailed status information, if available
97
184
  */
@@ -114,6 +201,62 @@ export type JobState = {
114
201
  endTime?: string | null;
115
202
  };
116
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
+
117
260
  /**
118
261
  * Response returned by async endpoints (`202 Accepted`). The `jobId` is deterministic for the
119
262
  * same input parameters — repeated calls with identical params return the same id.
@@ -344,13 +487,47 @@ export type GetInstrumentsError = GetInstrumentsErrors[keyof GetInstrumentsError
344
487
 
345
488
  export type GetInstrumentsResponses = {
346
489
  /**
347
- * A JSON array of Instrument details with data availability
490
+ * The default (spot) segment's instruments in `data`, `meta`, and HAL `_links` (self + spot/futures segment discovery)
348
491
  */
349
- 200: Array<InstrumentDetail>;
492
+ 200: InstrumentListResponse;
350
493
  };
351
494
 
352
495
  export type GetInstrumentsResponse = GetInstrumentsResponses[keyof GetInstrumentsResponses];
353
496
 
497
+ export type GetSegmentInstrumentsData = {
498
+ body?: never;
499
+ path: {
500
+ /**
501
+ * ID of the exchange to retrieve instruments for
502
+ */
503
+ exchangeId: string;
504
+ /**
505
+ * Market segment to list instruments for
506
+ */
507
+ segment: 'spot' | 'futures';
508
+ };
509
+ query?: never;
510
+ url: '/exchange/{exchangeId}/{segment}/instruments';
511
+ };
512
+
513
+ export type GetSegmentInstrumentsErrors = {
514
+ /**
515
+ * Exchange, segment, or instrument catalog not found
516
+ */
517
+ 404: ResponseError;
518
+ };
519
+
520
+ export type GetSegmentInstrumentsError = GetSegmentInstrumentsErrors[keyof GetSegmentInstrumentsErrors];
521
+
522
+ export type GetSegmentInstrumentsResponses = {
523
+ /**
524
+ * An object with a `data` array of instrument details (each with per-data-type coverage) and a `meta` block
525
+ */
526
+ 200: InstrumentListResponse;
527
+ };
528
+
529
+ export type GetSegmentInstrumentsResponse = GetSegmentInstrumentsResponses[keyof GetSegmentInstrumentsResponses];
530
+
354
531
  export type GetExchangeTickersHourData = {
355
532
  body?: never;
356
533
  path: {
@@ -671,7 +848,7 @@ export type GetPreparationStatusResponses = {
671
848
  /**
672
849
  * Current prepare job state
673
850
  */
674
- 200: JobState;
851
+ 200: PrepareJobState;
675
852
  };
676
853
 
677
854
  export type GetPreparationStatusResponse = GetPreparationStatusResponses[keyof GetPreparationStatusResponses];