@qtsurfer/api-client 0.14.1 → 0.16.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.
@@ -9,6 +9,10 @@ import type {
9
9
  AuthenticateData,
10
10
  AuthenticateResponse,
11
11
  AuthenticateError,
12
+ GetAccountData,
13
+ GetAccountResponse,
14
+ GetAccountUsageData,
15
+ GetAccountUsageResponse,
12
16
  ListExchangesData,
13
17
  ListExchangesResponse,
14
18
  ListInstrumentsData,
@@ -90,6 +94,12 @@ import type {
90
94
  GetDatasetUploadData,
91
95
  GetDatasetUploadResponse,
92
96
  GetDatasetUploadError,
97
+ ImportDatasetData,
98
+ ImportDatasetResponse,
99
+ ImportDatasetError,
100
+ GetDatasetImportData,
101
+ GetDatasetImportResponse,
102
+ GetDatasetImportError,
93
103
  } from "./types.gen";
94
104
  import { client as _heyApiClient } from "./client.gen";
95
105
 
@@ -141,6 +151,60 @@ export const authenticate = <ThrowOnError extends boolean = false>(
141
151
  });
142
152
  };
143
153
 
154
+ /**
155
+ * Get your account's identity and tier limits
156
+ * Your userId, current tier, and that tier's limits — no database call, safe to fetch on
157
+ * every page load. For live usage against these limits, see `_links.usage`
158
+ * (`GET /account/usage`).
159
+ *
160
+ */
161
+ export const getAccount = <ThrowOnError extends boolean = false>(
162
+ options?: Options<GetAccountData, ThrowOnError>
163
+ ) => {
164
+ return (options?.client ?? _heyApiClient).get<
165
+ GetAccountResponse,
166
+ unknown,
167
+ ThrowOnError
168
+ >({
169
+ security: [
170
+ {
171
+ scheme: "bearer",
172
+ type: "http",
173
+ },
174
+ ],
175
+ url: "/account",
176
+ ...options,
177
+ });
178
+ };
179
+
180
+ /**
181
+ * Get your live storage usage
182
+ * How much of your account's shared storage pool (`GET /account`'s `maxTotalStorageBytes`)
183
+ * you're currently using. Datasets, strategy-execution signals, and registered strategies
184
+ * all count against the same total — they compete for the same underlying storage, so
185
+ * there's one number to watch, not one per resource type. Not guaranteed real-time — a
186
+ * just-completed upload or strategy execution may take a short moment to be reflected here.
187
+ *
188
+ */
189
+ export const getAccountUsage = <ThrowOnError extends boolean = false>(
190
+ options?: Options<GetAccountUsageData, ThrowOnError>
191
+ ) => {
192
+ return (options?.client ?? _heyApiClient).get<
193
+ GetAccountUsageResponse,
194
+ unknown,
195
+ ThrowOnError
196
+ >({
197
+ security: [
198
+ {
199
+ scheme: "bearer",
200
+ type: "http",
201
+ },
202
+ ],
203
+ url: "/account/usage",
204
+ ...options,
205
+ });
206
+ };
207
+
144
208
  /**
145
209
  * List the available exchanges
146
210
  */
@@ -750,15 +814,22 @@ export const getSweepRunEquityCurve = <ThrowOnError extends boolean = false>(
750
814
  * backtest result with the curve included.
751
815
  *
752
816
  * The same request (same `prepareJobId`, `strategyId`, `storeSignals`, `equityCurve`,
753
- * `params`) always returns the same `jobId` (idempotent) — a request that omits `equityCurve`
754
- * or `params` dedupes exactly as it did before those fields existed. Two different `params`
755
- * vectors over one prepare are two different jobs, and `9` and `9.0` are the same one.
817
+ * `baseConfig`, `params`) always returns the same `jobId` (idempotent) — a request that omits
818
+ * `equityCurve`, `baseConfig` or `params` dedupes exactly as it did before those fields
819
+ * existed. Two different `params` vectors over one prepare are two different jobs, and `9`
820
+ * and `9.0` are the same one.
756
821
  *
757
822
  * The re-run is an independent execution rather than a replay of the sweep trial — the two
758
823
  * paths do not share a simulator — but they are pinned to agree: one vector run both ways
759
824
  * matches on every leaderboard metric, asserted as a regression test. Treat a difference as a
760
825
  * bug worth reporting, not as expected behaviour.
761
826
  *
827
+ * Optionally takes `baseConfig`, the same `SweepBaseConfig` shape `executeSweep` accepts —
828
+ * `initialFunding`, `feeRate`, `percentAmountToLock`, etc. — so the same object can be reused
829
+ * against either endpoint. This endpoint has one effective fee rate rather than a sweep's
830
+ * independent buy/sell legs: a `baseConfig` that resolves to different buy/sell rates, or sets
831
+ * a non-default `feeLeg`, is rejected with `400` rather than silently collapsed to one side.
832
+ *
762
833
  * Works unchanged for a dataset-backed prepare (`exchangeId: user`) — the request body is
763
834
  * identical either way, since the instrument and range are recovered from `prepareJobId`.
764
835
  *
@@ -882,16 +953,21 @@ export const listDatasets = <ThrowOnError extends boolean = false>(
882
953
  * response. `instrument` must be a plain spot pair (`BASE/QUOTE`, exactly one `/`); derivative
883
954
  * forms (e.g. `BTC/USDT:USDT`) are rejected.
884
955
  *
885
- * **Upload format.** A CSV with a header row, or a parquet file with the same columns by
886
- * name. Required: `timestamp` (ISO-8601, or numeric epoch seconds/millis/micros — detected
887
- * from the first row, then enforced for every later row), `close`. Optional: `open`, `high`,
888
- * `low`, `volume`, `quoteVolume`, `bid`, `bidSize`, `ask`, `askSize`. Cadence and timestamp
889
- * unit are discovered from the data, not declared.
956
+ * **Upload format.** A CSV with a header row, a parquet file with the same columns by
957
+ * name, or a lastra file — our own native columnar format, the same one a dataset's
958
+ * `dataUrl` hands back by default, so a downloaded dataset can be handed to another user to
959
+ * upload with no conversion in between. For CSV/parquet, required: `timestamp` (ISO-8601, or
960
+ * numeric epoch seconds/millis/micros — detected from the first row, then enforced for every
961
+ * later row), `close`. Optional: `open`, `high`, `low`, `volume`, `quoteVolume`, `bid`,
962
+ * `bidSize`, `ask`, `askSize`. A lastra upload carries its own fixed column set instead and
963
+ * only needs a timestamp series and a close series present. Cadence and timestamp unit are
964
+ * discovered from the data, not declared, for all three.
890
965
  *
891
966
  * A CSV upload is converted to our native columnar format (`lastra`) for storage. A parquet
892
- * upload is stored as-is today. Either way, always check `dataFormat` on
967
+ * or lastra upload is stored as-is today. Either way, always check `dataFormat` on
893
968
  * `GET /datasets/{datasetId}` and `GET /datasets/{datasetId}/uploads/{uploadId}` for which
894
- * one `dataUrl` actually is, rather than assuming from how you uploaded it.
969
+ * one `dataUrl` actually is, rather than assuming from how you uploaded it (a converted CSV
970
+ * and an uploaded lastra file both report `dataFormat: "lastra"`).
895
971
  *
896
972
  * The bytes PUT to `upload.url` may be that file directly, gzipped (`.gz`), or zipped
897
973
  * (`.zip`, exactly one file inside — a dataset is one file regardless of how it travels).
@@ -1059,3 +1135,77 @@ export const getDatasetUpload = <ThrowOnError extends boolean = false>(
1059
1135
  ...options,
1060
1136
  });
1061
1137
  };
1138
+
1139
+ /**
1140
+ * Create a dataset by importing history instead of uploading it
1141
+ * A second way to get data into a dataset, alongside `POST /datasets`: instead of `PUT`ting a
1142
+ * file yourself, ask the API to go fetch history on your behalf. Creates the dataset and
1143
+ * starts the fetch in the same call — there is no separate upload step, and the result lands
1144
+ * as a dataset version indistinguishable from an uploaded one once it's ready. Poll
1145
+ * `GET /datasets/{datasetId}/imports/{importId}` for progress.
1146
+ *
1147
+ * `type` selects the source. `dex` — history over a pool/pair's own on-chain market — is the
1148
+ * only value today; other source types join this same endpoint later.
1149
+ *
1150
+ * A `dex` import has two data shapes, chosen by the top-level `cadence`:
1151
+ *
1152
+ * * Omitted/blank (default) — on-chain swap history, replayed directly from the pool/pair's
1153
+ * own chain. Cadence is native, not resampled: each swap keeps the timestamp it happened
1154
+ * at rather than being bucketed into candles, so the resulting version's `cadence` is `rt`
1155
+ * unless the swaps happen to sit on a fixed grid (see `DatasetVersion.cadence`).
1156
+ * * One of `1s` / `1m` / `5m` — pre-aggregated candles at that width instead of raw trades.
1157
+ * The resulting dataset's `type` is `klines`, not `ticker`. Not every network supports every
1158
+ * cadence yet — an unsupported combination fails asynchronously, same as an unresolvable
1159
+ * pool (see the `failed` status on the poll endpoint below).
1160
+ *
1161
+ */
1162
+ export const importDataset = <ThrowOnError extends boolean = false>(
1163
+ options: Options<ImportDatasetData, ThrowOnError>
1164
+ ) => {
1165
+ return (options.client ?? _heyApiClient).post<
1166
+ ImportDatasetResponse,
1167
+ ImportDatasetError,
1168
+ ThrowOnError
1169
+ >({
1170
+ security: [
1171
+ {
1172
+ scheme: "bearer",
1173
+ type: "http",
1174
+ },
1175
+ ],
1176
+ url: "/datasets/imports",
1177
+ ...options,
1178
+ headers: {
1179
+ "Content-Type": "application/json",
1180
+ ...options?.headers,
1181
+ },
1182
+ });
1183
+ };
1184
+
1185
+ /**
1186
+ * Get the state of an import/ingest
1187
+ * Poll after `POST /datasets/imports` until `status` is `ready` or `failed`. An import spends
1188
+ * real time fetching from its source before anything is even staged — `fetching` is the one
1189
+ * status only an import ever reports; `ingesting`/`ready`/`failed` mean exactly what they do
1190
+ * on `GET /datasets/{datasetId}/uploads/{uploadId}`, since an import re-enters that same
1191
+ * ingest chain once it has fetched and staged its data.
1192
+ *
1193
+ */
1194
+ export const getDatasetImport = <ThrowOnError extends boolean = false>(
1195
+ options: Options<GetDatasetImportData, ThrowOnError>
1196
+ ) => {
1197
+ return (options.client ?? _heyApiClient).get<
1198
+ GetDatasetImportResponse,
1199
+ GetDatasetImportError,
1200
+ ThrowOnError
1201
+ >({
1202
+ security: [
1203
+ {
1204
+ scheme: "bearer",
1205
+ type: "http",
1206
+ },
1207
+ ],
1208
+ url: "/datasets/{datasetId}/imports/{importId}",
1209
+ ...options,
1210
+ });
1211
+ };