@qtsurfer/api-client 0.14.0 → 0.15.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 +4 -2
- package/dist/index.d.ts +383 -43
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/generated/schemas.gen.ts +322 -61
- package/src/generated/sdk.gen.ts +106 -8
- package/src/generated/types.gen.ts +342 -51
package/src/generated/sdk.gen.ts
CHANGED
|
@@ -90,6 +90,12 @@ import type {
|
|
|
90
90
|
GetDatasetUploadData,
|
|
91
91
|
GetDatasetUploadResponse,
|
|
92
92
|
GetDatasetUploadError,
|
|
93
|
+
ImportDatasetData,
|
|
94
|
+
ImportDatasetResponse,
|
|
95
|
+
ImportDatasetError,
|
|
96
|
+
GetDatasetImportData,
|
|
97
|
+
GetDatasetImportResponse,
|
|
98
|
+
GetDatasetImportError,
|
|
93
99
|
} from "./types.gen";
|
|
94
100
|
import { client as _heyApiClient } from "./client.gen";
|
|
95
101
|
|
|
@@ -750,15 +756,22 @@ export const getSweepRunEquityCurve = <ThrowOnError extends boolean = false>(
|
|
|
750
756
|
* backtest result with the curve included.
|
|
751
757
|
*
|
|
752
758
|
* The same request (same `prepareJobId`, `strategyId`, `storeSignals`, `equityCurve`,
|
|
753
|
-
* `params`) always returns the same `jobId` (idempotent) — a request that omits
|
|
754
|
-
* or `params` dedupes exactly as it did before those fields
|
|
755
|
-
* vectors over one prepare are two different jobs, and `9`
|
|
759
|
+
* `baseConfig`, `params`) always returns the same `jobId` (idempotent) — a request that omits
|
|
760
|
+
* `equityCurve`, `baseConfig` or `params` dedupes exactly as it did before those fields
|
|
761
|
+
* existed. Two different `params` vectors over one prepare are two different jobs, and `9`
|
|
762
|
+
* and `9.0` are the same one.
|
|
756
763
|
*
|
|
757
764
|
* The re-run is an independent execution rather than a replay of the sweep trial — the two
|
|
758
765
|
* paths do not share a simulator — but they are pinned to agree: one vector run both ways
|
|
759
766
|
* matches on every leaderboard metric, asserted as a regression test. Treat a difference as a
|
|
760
767
|
* bug worth reporting, not as expected behaviour.
|
|
761
768
|
*
|
|
769
|
+
* Optionally takes `baseConfig`, the same `SweepBaseConfig` shape `executeSweep` accepts —
|
|
770
|
+
* `initialFunding`, `feeRate`, `percentAmountToLock`, etc. — so the same object can be reused
|
|
771
|
+
* against either endpoint. This endpoint has one effective fee rate rather than a sweep's
|
|
772
|
+
* independent buy/sell legs: a `baseConfig` that resolves to different buy/sell rates, or sets
|
|
773
|
+
* a non-default `feeLeg`, is rejected with `400` rather than silently collapsed to one side.
|
|
774
|
+
*
|
|
762
775
|
* Works unchanged for a dataset-backed prepare (`exchangeId: user`) — the request body is
|
|
763
776
|
* identical either way, since the instrument and range are recovered from `prepareJobId`.
|
|
764
777
|
*
|
|
@@ -882,11 +895,22 @@ export const listDatasets = <ThrowOnError extends boolean = false>(
|
|
|
882
895
|
* response. `instrument` must be a plain spot pair (`BASE/QUOTE`, exactly one `/`); derivative
|
|
883
896
|
* forms (e.g. `BTC/USDT:USDT`) are rejected.
|
|
884
897
|
*
|
|
885
|
-
* **Upload format.** A CSV with a header row
|
|
886
|
-
* numeric epoch seconds/millis/micros — detected
|
|
887
|
-
* later row), `close`. Optional
|
|
888
|
-
* `bid`, `bidSize`, `ask`, `askSize`. Cadence and timestamp
|
|
889
|
-
* not declared.
|
|
898
|
+
* **Upload format.** A CSV with a header row, or a parquet file with the same columns by
|
|
899
|
+
* name. Required: `timestamp` (ISO-8601, or numeric epoch seconds/millis/micros — detected
|
|
900
|
+
* from the first row, then enforced for every later row), `close`. Optional: `open`, `high`,
|
|
901
|
+
* `low`, `volume`, `quoteVolume`, `bid`, `bidSize`, `ask`, `askSize`. Cadence and timestamp
|
|
902
|
+
* unit are discovered from the data, not declared.
|
|
903
|
+
*
|
|
904
|
+
* A CSV upload is converted to our native columnar format (`lastra`) for storage. A parquet
|
|
905
|
+
* upload is stored as-is today. Either way, always check `dataFormat` on
|
|
906
|
+
* `GET /datasets/{datasetId}` and `GET /datasets/{datasetId}/uploads/{uploadId}` for which
|
|
907
|
+
* one `dataUrl` actually is, rather than assuming from how you uploaded it.
|
|
908
|
+
*
|
|
909
|
+
* The bytes PUT to `upload.url` may be that file directly, gzipped (`.gz`), or zipped
|
|
910
|
+
* (`.zip`, exactly one file inside — a dataset is one file regardless of how it travels).
|
|
911
|
+
* Format is detected from the decompressed content itself: there is no filename or
|
|
912
|
+
* `Content-Type` anywhere in this flow for a client to declare it with, so nothing needs to
|
|
913
|
+
* be sent besides the bytes.
|
|
890
914
|
*
|
|
891
915
|
*/
|
|
892
916
|
export const createDataset = <ThrowOnError extends boolean = false>(
|
|
@@ -1048,3 +1072,77 @@ export const getDatasetUpload = <ThrowOnError extends boolean = false>(
|
|
|
1048
1072
|
...options,
|
|
1049
1073
|
});
|
|
1050
1074
|
};
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Create a dataset by importing history instead of uploading it
|
|
1078
|
+
* A second way to get data into a dataset, alongside `POST /datasets`: instead of `PUT`ting a
|
|
1079
|
+
* file yourself, ask the API to go fetch history on your behalf. Creates the dataset and
|
|
1080
|
+
* starts the fetch in the same call — there is no separate upload step, and the result lands
|
|
1081
|
+
* as a dataset version indistinguishable from an uploaded one once it's ready. Poll
|
|
1082
|
+
* `GET /datasets/{datasetId}/imports/{importId}` for progress.
|
|
1083
|
+
*
|
|
1084
|
+
* `type` selects the source. `dex` — history over a pool/pair's own on-chain market — is the
|
|
1085
|
+
* only value today; other source types join this same endpoint later.
|
|
1086
|
+
*
|
|
1087
|
+
* A `dex` import has two data shapes, chosen by the top-level `cadence`:
|
|
1088
|
+
*
|
|
1089
|
+
* * Omitted/blank (default) — on-chain swap history, replayed directly from the pool/pair's
|
|
1090
|
+
* own chain. Cadence is native, not resampled: each swap keeps the timestamp it happened
|
|
1091
|
+
* at rather than being bucketed into candles, so the resulting version's `cadence` is `rt`
|
|
1092
|
+
* unless the swaps happen to sit on a fixed grid (see `DatasetVersion.cadence`).
|
|
1093
|
+
* * One of `1s` / `1m` / `5m` — pre-aggregated candles at that width instead of raw trades.
|
|
1094
|
+
* The resulting dataset's `type` is `klines`, not `ticker`. Not every network supports every
|
|
1095
|
+
* cadence yet — an unsupported combination fails asynchronously, same as an unresolvable
|
|
1096
|
+
* pool (see the `failed` status on the poll endpoint below).
|
|
1097
|
+
*
|
|
1098
|
+
*/
|
|
1099
|
+
export const importDataset = <ThrowOnError extends boolean = false>(
|
|
1100
|
+
options: Options<ImportDatasetData, ThrowOnError>
|
|
1101
|
+
) => {
|
|
1102
|
+
return (options.client ?? _heyApiClient).post<
|
|
1103
|
+
ImportDatasetResponse,
|
|
1104
|
+
ImportDatasetError,
|
|
1105
|
+
ThrowOnError
|
|
1106
|
+
>({
|
|
1107
|
+
security: [
|
|
1108
|
+
{
|
|
1109
|
+
scheme: "bearer",
|
|
1110
|
+
type: "http",
|
|
1111
|
+
},
|
|
1112
|
+
],
|
|
1113
|
+
url: "/datasets/imports",
|
|
1114
|
+
...options,
|
|
1115
|
+
headers: {
|
|
1116
|
+
"Content-Type": "application/json",
|
|
1117
|
+
...options?.headers,
|
|
1118
|
+
},
|
|
1119
|
+
});
|
|
1120
|
+
};
|
|
1121
|
+
|
|
1122
|
+
/**
|
|
1123
|
+
* Get the state of an import/ingest
|
|
1124
|
+
* Poll after `POST /datasets/imports` until `status` is `ready` or `failed`. An import spends
|
|
1125
|
+
* real time fetching from its source before anything is even staged — `fetching` is the one
|
|
1126
|
+
* status only an import ever reports; `ingesting`/`ready`/`failed` mean exactly what they do
|
|
1127
|
+
* on `GET /datasets/{datasetId}/uploads/{uploadId}`, since an import re-enters that same
|
|
1128
|
+
* ingest chain once it has fetched and staged its data.
|
|
1129
|
+
*
|
|
1130
|
+
*/
|
|
1131
|
+
export const getDatasetImport = <ThrowOnError extends boolean = false>(
|
|
1132
|
+
options: Options<GetDatasetImportData, ThrowOnError>
|
|
1133
|
+
) => {
|
|
1134
|
+
return (options.client ?? _heyApiClient).get<
|
|
1135
|
+
GetDatasetImportResponse,
|
|
1136
|
+
GetDatasetImportError,
|
|
1137
|
+
ThrowOnError
|
|
1138
|
+
>({
|
|
1139
|
+
security: [
|
|
1140
|
+
{
|
|
1141
|
+
scheme: "bearer",
|
|
1142
|
+
type: "http",
|
|
1143
|
+
},
|
|
1144
|
+
],
|
|
1145
|
+
url: "/datasets/{datasetId}/imports/{importId}",
|
|
1146
|
+
...options,
|
|
1147
|
+
});
|
|
1148
|
+
};
|