@qtsurfer/api-client 0.4.0 → 0.6.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 +22 -22
- package/dist/index.d.ts +365 -110
- package/dist/index.js +69 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/generated/schemas.gen.ts +379 -0
- package/src/generated/sdk.gen.ts +97 -32
- package/src/generated/types.gen.ts +342 -91
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ npm install @qtsurfer/api-client
|
|
|
26
26
|
## Quick start
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
|
-
import { client,
|
|
29
|
+
import { client, listExchanges, prepareBacktest } from '@qtsurfer/api-client';
|
|
30
30
|
|
|
31
31
|
client.setConfig({
|
|
32
32
|
baseUrl: 'https://api.qtsurfer.com/v1',
|
|
@@ -35,7 +35,7 @@ client.setConfig({
|
|
|
35
35
|
},
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
const { data: exchanges, error } = await
|
|
38
|
+
const { data: exchanges, error } = await listExchanges();
|
|
39
39
|
if (error) throw error;
|
|
40
40
|
|
|
41
41
|
console.log(exchanges);
|
|
@@ -44,12 +44,12 @@ console.log(exchanges);
|
|
|
44
44
|
### API key → JWT
|
|
45
45
|
|
|
46
46
|
Every endpoint above expects a short-lived JWT in `Authorization: Bearer …`.
|
|
47
|
-
Exchange a long-lived API key for one via `
|
|
47
|
+
Exchange a long-lived API key for one via `authenticate`:
|
|
48
48
|
|
|
49
49
|
```ts
|
|
50
|
-
import {
|
|
50
|
+
import { authenticate } from '@qtsurfer/api-client';
|
|
51
51
|
|
|
52
|
-
const { data, error } = await
|
|
52
|
+
const { data, error } = await authenticate({
|
|
53
53
|
baseUrl: 'https://api.qtsurfer.com/v1',
|
|
54
54
|
headers: { 'X-API-Key': process.env.QTSURFER_APIKEY! },
|
|
55
55
|
});
|
|
@@ -59,7 +59,7 @@ const { access_token: jwt } = data; // feed to client.setConfig() for the rest
|
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
For production use, prefer the [`@qtsurfer/sdk`](https://github.com/QTSurfer/sdk-ts)
|
|
62
|
-
`
|
|
62
|
+
`authenticate(apikey)` helper — it returns a session that refreshes the JWT
|
|
63
63
|
transparently, reads `QTSURFER_APIKEY` from the environment, and supports
|
|
64
64
|
pluggable token stores so callers don't reinvent that plumbing.
|
|
65
65
|
|
|
@@ -69,18 +69,18 @@ All operations are exported as standalone functions; every operation accepts an
|
|
|
69
69
|
|
|
70
70
|
| Function | Method | Path | Purpose |
|
|
71
71
|
| -------- | ------ | ---- | ------- |
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
72
|
+
| `authenticate` | POST | `/auth/token` | Exchange an API key for a short-lived JWT |
|
|
73
|
+
| `listExchanges` | GET | `/exchanges` | List available exchanges |
|
|
74
|
+
| `listInstruments` | GET | `/exchange/{exchangeId}/instruments` | List instruments for an exchange |
|
|
75
|
+
| `downloadTickers` | GET | `/exchange/{exchangeId}/tickers/{base}/{quote}` | Download one hour of tickers as Lastra/Parquet |
|
|
76
|
+
| `downloadKlines` | GET | `/exchange/{exchangeId}/klines/{base}/{quote}` | Download one hour of klines as Lastra/Parquet |
|
|
77
|
+
| `compileStrategy` | POST | `/strategy` | Compile a strategy |
|
|
78
|
+
| `getStrategy` | GET | `/strategy/{strategyId}` | Poll strategy compilation status |
|
|
79
|
+
| `prepareBacktest` | POST | `/backtesting/prepare` | Start a data preparation job |
|
|
80
|
+
| `getPrepareStatus` | GET | `/backtesting/prepare/{jobId}` | Poll preparation status |
|
|
81
|
+
| `executeBacktest` | POST | `/backtesting/execute` | Start a backtest execution |
|
|
82
|
+
| `cancelBacktest` | POST | `/backtesting/execute/{jobId}/cancel` | Cancel a running execution |
|
|
83
|
+
| `getBacktestResult` | GET | `/backtesting/execute/{jobId}` | Poll or fetch execution results |
|
|
84
84
|
|
|
85
85
|
All generated types (`Exchange`, `InstrumentDetail`, `BacktestJobResult`, `PrepareJobState`, `ResultMap`, etc.) are re-exported from the root.
|
|
86
86
|
|
|
@@ -89,7 +89,7 @@ All generated types (`Exchange`, `InstrumentDetail`, `BacktestJobResult`, `Prepa
|
|
|
89
89
|
The default client points to the staging server. Override via `setConfig` or by passing options inline:
|
|
90
90
|
|
|
91
91
|
```ts
|
|
92
|
-
import { client,
|
|
92
|
+
import { client, listExchanges } from '@qtsurfer/api-client';
|
|
93
93
|
|
|
94
94
|
// Global
|
|
95
95
|
client.setConfig({
|
|
@@ -97,7 +97,7 @@ client.setConfig({
|
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
// Per-call
|
|
100
|
-
await
|
|
100
|
+
await listExchanges({
|
|
101
101
|
baseUrl: 'https://api.qtsurfer.com/v1',
|
|
102
102
|
headers: { 'X-Request-Id': '...' },
|
|
103
103
|
});
|
|
@@ -110,9 +110,9 @@ To build your own isolated client (e.g. per-tenant), use `createClient` from `@h
|
|
|
110
110
|
Each function returns a discriminated union. Narrow via `error` before using `data`:
|
|
111
111
|
|
|
112
112
|
```ts
|
|
113
|
-
const { data, error } = await
|
|
113
|
+
const { data, error } = await prepareBacktest({
|
|
114
114
|
body: {
|
|
115
|
-
/*
|
|
115
|
+
/* PrepareRequest */
|
|
116
116
|
},
|
|
117
117
|
});
|
|
118
118
|
|