@qtsurfer/api-client 0.19.0 → 0.21.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 +30 -11
- package/dist/index.d.ts +451 -36
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/generated/schemas.gen.ts +275 -12
- package/src/generated/sdk.gen.ts +179 -9
- package/src/generated/types.gen.ts +390 -24
package/src/generated/sdk.gen.ts
CHANGED
|
@@ -115,12 +115,24 @@ import type {
|
|
|
115
115
|
ListPublicLiveData,
|
|
116
116
|
ListPublicLiveResponse,
|
|
117
117
|
ListPublicLiveError,
|
|
118
|
+
GetLiveRunData,
|
|
119
|
+
GetLiveRunResponse,
|
|
120
|
+
GetLiveRunError,
|
|
118
121
|
UpdateLiveData,
|
|
119
122
|
UpdateLiveResponse,
|
|
120
123
|
UpdateLiveError,
|
|
121
124
|
UpdateLiveParamsData,
|
|
122
125
|
UpdateLiveParamsResponse,
|
|
123
126
|
UpdateLiveParamsError,
|
|
127
|
+
SendLiveCommandData,
|
|
128
|
+
SendLiveCommandResponse,
|
|
129
|
+
SendLiveCommandError,
|
|
130
|
+
RevokeLiveStreamData,
|
|
131
|
+
RevokeLiveStreamResponse,
|
|
132
|
+
RevokeLiveStreamError,
|
|
133
|
+
RotateLiveStreamData,
|
|
134
|
+
RotateLiveStreamResponse,
|
|
135
|
+
RotateLiveStreamError,
|
|
124
136
|
GetLiveRunSignalsData,
|
|
125
137
|
GetLiveRunSignalsResponse,
|
|
126
138
|
GetLiveRunSignalsError,
|
|
@@ -374,6 +386,10 @@ export const downloadKlines = <ThrowOnError extends boolean = false>(
|
|
|
374
386
|
* many strategies you have. Check a specific strategy's validation with `GET
|
|
375
387
|
* /strategy/{strategyId}`.
|
|
376
388
|
*
|
|
389
|
+
* With `includeDeleted=true`, strategies you have deleted are listed too, each with the
|
|
390
|
+
* `deletedAt` it was deleted at — useful to keep a copy of your list in sync, telling a
|
|
391
|
+
* deleted strategy apart from one that never existed.
|
|
392
|
+
*
|
|
377
393
|
*/
|
|
378
394
|
export const listStrategies = <ThrowOnError extends boolean = false>(
|
|
379
395
|
options?: Options<ListStrategiesData, ThrowOnError>
|
|
@@ -411,6 +427,11 @@ export const listStrategies = <ThrowOnError extends boolean = false>(
|
|
|
411
427
|
* included, is read from `GET /strategy/{strategyId}`. One place to ask, so there is no second
|
|
412
428
|
* answer to keep in step.
|
|
413
429
|
*
|
|
430
|
+
* A `200` means the source parsed and compiled, not that it will run. What only shows once the
|
|
431
|
+
* strategy sets up its indicators is found by `validate`: for QTScript, a window on an indicator
|
|
432
|
+
* name that is not registered (`window nosuch m1 { ... }`) registers, and `validate` ends `failed`
|
|
433
|
+
* on that line.
|
|
434
|
+
*
|
|
414
435
|
* For **Java**, the `strategyId` is derived from what the code *means*, not from how it is
|
|
415
436
|
* written. Adding a comment, inserting a blank line, re-indenting, reordering imports, or
|
|
416
437
|
* moving a method around all return the **same** id — you have not created a second strategy.
|
|
@@ -976,6 +997,10 @@ export const getBacktestResult = <ThrowOnError extends boolean = false>(
|
|
|
976
997
|
* Every dataset you have created and not deleted, most recently created first. Never a `404`
|
|
977
998
|
* — an empty array if you have none, same convention as `GET /strategies`.
|
|
978
999
|
*
|
|
1000
|
+
* With `includeDeleted=true`, datasets you have deleted are listed too, each with the
|
|
1001
|
+
* `deletedAt` it was deleted at — useful to keep a copy of your list in sync, telling a
|
|
1002
|
+
* deleted dataset apart from one that never existed.
|
|
1003
|
+
*
|
|
979
1004
|
*/
|
|
980
1005
|
export const listDatasets = <ThrowOnError extends boolean = false>(
|
|
981
1006
|
options?: Options<ListDatasetsData, ThrowOnError>
|
|
@@ -1273,7 +1298,8 @@ export const getDatasetImport = <ThrowOnError extends boolean = false>(
|
|
|
1273
1298
|
* Requests a stop. The run winds down at its own next check-in rather than instantly —
|
|
1274
1299
|
* poll `GET`/`PATCH` `.../live` and expect `state` to remain `RUNNING` for a short window
|
|
1275
1300
|
* after `desired` flips to `STOPPED`. Calling this again on an already-stopped run is not an
|
|
1276
|
-
* error; it returns the same (unchanged) state.
|
|
1301
|
+
* error; it returns the same (unchanged) state. A stopped run has no stream: its `streamUrl`, if it had one,
|
|
1302
|
+
* stops working and is not in this response.
|
|
1277
1303
|
*
|
|
1278
1304
|
*/
|
|
1279
1305
|
export const stopLive = <ThrowOnError extends boolean = false>(
|
|
@@ -1299,7 +1325,12 @@ export const stopLive = <ThrowOnError extends boolean = false>(
|
|
|
1299
1325
|
* Get this strategy's current (or most recent) live run
|
|
1300
1326
|
* The run you last started for this strategy — its most complete state, including `params`
|
|
1301
1327
|
* and the promotion `gate` once the sandbox trial has one to report. Returns the run's last
|
|
1302
|
-
* known state even after it has stopped; this endpoint never disappears history.
|
|
1328
|
+
* known state even after it has stopped; this endpoint never disappears history. When the run was started
|
|
1329
|
+
* with a `stream`, `streamUrl` is here too while the run is running and your plan allows it.
|
|
1330
|
+
*
|
|
1331
|
+
* While the run is being executed it also carries `stats`, the run's latest counters (updates
|
|
1332
|
+
* processed, rate, instruments seen), refreshed about once a minute. Starting or stopping a run
|
|
1333
|
+
* does not return them; read them here.
|
|
1303
1334
|
*
|
|
1304
1335
|
*/
|
|
1305
1336
|
export const getLive = <ThrowOnError extends boolean = false>(
|
|
@@ -1356,6 +1387,11 @@ export const getLive = <ThrowOnError extends boolean = false>(
|
|
|
1356
1387
|
* (it overrides `getExecutionCallback()`) has no other execution venue, so it cannot start
|
|
1357
1388
|
* without a `paper` block.
|
|
1358
1389
|
*
|
|
1390
|
+
* **A plain WebSocket stream.** Pass `stream: true` to get a secret URL for this run's signals that a simple
|
|
1391
|
+
* client, or a service that passes them on to others, can open as an ordinary WebSocket, from the sandbox stage
|
|
1392
|
+
* on. The URL is in the response (`streamUrl`) and in `GET /strategy/{strategyId}/live`; treat it like a
|
|
1393
|
+
* password. See the "Live execution" guide.
|
|
1394
|
+
*
|
|
1359
1395
|
*/
|
|
1360
1396
|
export const startLive = <ThrowOnError extends boolean = false>(
|
|
1361
1397
|
options: Options<StartLiveData, ThrowOnError>
|
|
@@ -1408,8 +1444,9 @@ export const listLive = <ThrowOnError extends boolean = false>(
|
|
|
1408
1444
|
|
|
1409
1445
|
/**
|
|
1410
1446
|
* Browse public live runs
|
|
1411
|
-
* Every run whose owner marked it `public
|
|
1412
|
-
* yours included, and listed without revealing who owns it.
|
|
1447
|
+
* Every run whose owner marked it `public`, that has been promoted to `live` and is running —
|
|
1448
|
+
* anyone's, yours included, and listed without revealing who owns it. A `public` run still in
|
|
1449
|
+
* its `sandbox` trial is not listed. Most recently started first.
|
|
1413
1450
|
*
|
|
1414
1451
|
* This is the only `Live Execution` endpoint that needs no `Authorization` header.
|
|
1415
1452
|
*
|
|
@@ -1427,6 +1464,40 @@ export const listPublicLive = <ThrowOnError extends boolean = false>(
|
|
|
1427
1464
|
});
|
|
1428
1465
|
};
|
|
1429
1466
|
|
|
1467
|
+
/**
|
|
1468
|
+
* Read one of your runs by its id
|
|
1469
|
+
* Owner only, addressed by `runId` directly rather than through its strategy: the run's own
|
|
1470
|
+
* canonical identity, which is what `POST`/`GET`/`DELETE` `.../live`, `GET /live` and
|
|
1471
|
+
* `GET /live/public` all hand out. Use it to re-read one specific run — including one you
|
|
1472
|
+
* stopped long ago or that is no longer your strategy's most recent — without paging through
|
|
1473
|
+
* `GET /live`.
|
|
1474
|
+
*
|
|
1475
|
+
* Returns the same state as `GET /strategy/{strategyId}/live` (`strategyId` is the strategy's
|
|
1476
|
+
* id, and `stats` is there too), plus `updatedAtMs`: when the run last changed, from any cause — a
|
|
1477
|
+
* state change, a promotion, a parameter update, a stop. A refresh of `stats` is not a change of
|
|
1478
|
+
* the run and does not move `updatedAtMs`. A run that is public is reachable by others through
|
|
1479
|
+
* `GET /live/public`, never through this route.
|
|
1480
|
+
*
|
|
1481
|
+
*/
|
|
1482
|
+
export const getLiveRun = <ThrowOnError extends boolean = false>(
|
|
1483
|
+
options: Options<GetLiveRunData, ThrowOnError>
|
|
1484
|
+
) => {
|
|
1485
|
+
return (options.client ?? _heyApiClient).get<
|
|
1486
|
+
GetLiveRunResponse,
|
|
1487
|
+
GetLiveRunError,
|
|
1488
|
+
ThrowOnError
|
|
1489
|
+
>({
|
|
1490
|
+
security: [
|
|
1491
|
+
{
|
|
1492
|
+
scheme: "bearer",
|
|
1493
|
+
type: "http",
|
|
1494
|
+
},
|
|
1495
|
+
],
|
|
1496
|
+
url: "/live/{runId}",
|
|
1497
|
+
...options,
|
|
1498
|
+
});
|
|
1499
|
+
};
|
|
1500
|
+
|
|
1430
1501
|
/**
|
|
1431
1502
|
* Change a run's visibility, name, or description
|
|
1432
1503
|
* Owner only, addressed by `runId` directly rather than through its strategy — this is a
|
|
@@ -1498,6 +1569,103 @@ export const updateLiveParams = <ThrowOnError extends boolean = false>(
|
|
|
1498
1569
|
});
|
|
1499
1570
|
};
|
|
1500
1571
|
|
|
1572
|
+
/**
|
|
1573
|
+
* Tell a running strategy a command
|
|
1574
|
+
* Tells a running strategy something **while it stays live**, without restarting it — for a strategy that
|
|
1575
|
+
* implements the engine's `CommandRequestHandler`. Owner only.
|
|
1576
|
+
*
|
|
1577
|
+
* A command is an event, not a stored setting: it is delivered once to every execution behind the run, at
|
|
1578
|
+
* the same market position, and nothing about it is written to the run's state. **It is transient** — a
|
|
1579
|
+
* replica that restarts replays only its recent market history, so a command from before that only reaches
|
|
1580
|
+
* one that was already running when it arrived. Anything the strategy needs to remember across a restart
|
|
1581
|
+
* belongs in a parameter (`PUT /live/{runId}/params`), which does have a stored value; a command does not.
|
|
1582
|
+
*
|
|
1583
|
+
* The command's text is a plain string; an optional `properties` object of your own choosing travels
|
|
1584
|
+
* alongside it. Each entry lands as a top-level entry on the `CommandRequest` the handler receives —
|
|
1585
|
+
* `request.get("<key>")` in Java, `$command.<key>` sugar in QTScript — no key is off limits, since the
|
|
1586
|
+
* command's own text is kept separately.
|
|
1587
|
+
*
|
|
1588
|
+
*/
|
|
1589
|
+
export const sendLiveCommand = <ThrowOnError extends boolean = false>(
|
|
1590
|
+
options: Options<SendLiveCommandData, ThrowOnError>
|
|
1591
|
+
) => {
|
|
1592
|
+
return (options.client ?? _heyApiClient).post<
|
|
1593
|
+
SendLiveCommandResponse,
|
|
1594
|
+
SendLiveCommandError,
|
|
1595
|
+
ThrowOnError
|
|
1596
|
+
>({
|
|
1597
|
+
security: [
|
|
1598
|
+
{
|
|
1599
|
+
scheme: "bearer",
|
|
1600
|
+
type: "http",
|
|
1601
|
+
},
|
|
1602
|
+
],
|
|
1603
|
+
url: "/live/{runId}/commands",
|
|
1604
|
+
...options,
|
|
1605
|
+
headers: {
|
|
1606
|
+
"Content-Type": "application/json",
|
|
1607
|
+
...options?.headers,
|
|
1608
|
+
},
|
|
1609
|
+
});
|
|
1610
|
+
};
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* Revoke a run's stream URL
|
|
1614
|
+
* Revokes a run's stream URL **for good**: connections open on it are closed within about 15 seconds and it
|
|
1615
|
+
* answers `404` from then on. The run itself is not touched, and a stream cannot be added to it again; start
|
|
1616
|
+
* the run again with `stream: true` for a new URL. Owner only, and always allowed, whatever your plan or the
|
|
1617
|
+
* run's state. Repeating it is not an error.
|
|
1618
|
+
*
|
|
1619
|
+
*/
|
|
1620
|
+
export const revokeLiveStream = <ThrowOnError extends boolean = false>(
|
|
1621
|
+
options: Options<RevokeLiveStreamData, ThrowOnError>
|
|
1622
|
+
) => {
|
|
1623
|
+
return (options.client ?? _heyApiClient).delete<
|
|
1624
|
+
RevokeLiveStreamResponse,
|
|
1625
|
+
RevokeLiveStreamError,
|
|
1626
|
+
ThrowOnError
|
|
1627
|
+
>({
|
|
1628
|
+
security: [
|
|
1629
|
+
{
|
|
1630
|
+
scheme: "bearer",
|
|
1631
|
+
type: "http",
|
|
1632
|
+
},
|
|
1633
|
+
],
|
|
1634
|
+
url: "/live/{runId}/stream",
|
|
1635
|
+
...options,
|
|
1636
|
+
});
|
|
1637
|
+
};
|
|
1638
|
+
|
|
1639
|
+
/**
|
|
1640
|
+
* Rotate a run's stream URL
|
|
1641
|
+
* Gives a run a **new** stream URL and retires the old one: connections open on the old URL are closed
|
|
1642
|
+
* within about 15 seconds and the old URL answers `404` from then on. Use it when the URL may have leaked.
|
|
1643
|
+
* Owner only, and only for a run that is running and was started with `stream: true` (the URL cannot be added
|
|
1644
|
+
* to a run later, and a revoked one cannot be brought back). The plan is checked again: a plan that may not
|
|
1645
|
+
* broadcast gets `429`.
|
|
1646
|
+
*
|
|
1647
|
+
* See the "Live execution" guide, "A plain WebSocket stream of a run".
|
|
1648
|
+
*
|
|
1649
|
+
*/
|
|
1650
|
+
export const rotateLiveStream = <ThrowOnError extends boolean = false>(
|
|
1651
|
+
options: Options<RotateLiveStreamData, ThrowOnError>
|
|
1652
|
+
) => {
|
|
1653
|
+
return (options.client ?? _heyApiClient).post<
|
|
1654
|
+
RotateLiveStreamResponse,
|
|
1655
|
+
RotateLiveStreamError,
|
|
1656
|
+
ThrowOnError
|
|
1657
|
+
>({
|
|
1658
|
+
security: [
|
|
1659
|
+
{
|
|
1660
|
+
scheme: "bearer",
|
|
1661
|
+
type: "http",
|
|
1662
|
+
},
|
|
1663
|
+
],
|
|
1664
|
+
url: "/live/{runId}/stream",
|
|
1665
|
+
...options,
|
|
1666
|
+
});
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1501
1669
|
/**
|
|
1502
1670
|
* Read a run's signals
|
|
1503
1671
|
* Returns one page of the signals a run has already produced, newest-last, optionally from a
|
|
@@ -1521,8 +1689,9 @@ export const updateLiveParams = <ThrowOnError extends boolean = false>(
|
|
|
1521
1689
|
* serving a shortened page that looks complete. Treat that as a normal outcome: read
|
|
1522
1690
|
* `availableSinceMs` from the error and start again from there.
|
|
1523
1691
|
*
|
|
1524
|
-
* Readable by the run's owner, and by anyone if the run is `public`
|
|
1525
|
-
* signal channel applies to a subscription.
|
|
1692
|
+
* Readable by the run's owner, and by anyone if the run is `public` and has reached the `live`
|
|
1693
|
+
* stage — the same rule the signal channel applies to a subscription. A `sandbox` run is read
|
|
1694
|
+
* by its owner only, whatever visibility it asked for.
|
|
1526
1695
|
*
|
|
1527
1696
|
*/
|
|
1528
1697
|
export const getLiveRunSignals = <ThrowOnError extends boolean = false>(
|
|
@@ -1556,8 +1725,8 @@ export const getLiveRunSignals = <ThrowOnError extends boolean = false>(
|
|
|
1556
1725
|
* mark`, taken every minute of market time). Until either exists the account holds its
|
|
1557
1726
|
* starting capital.
|
|
1558
1727
|
*
|
|
1559
|
-
* Readable by the run's owner, and by anyone if the run is `public
|
|
1560
|
-
* a `paper` block answers `404`.
|
|
1728
|
+
* Readable by the run's owner, and by anyone if the run is `public` and has reached the `live`
|
|
1729
|
+
* stage. A run started without a `paper` block answers `404`.
|
|
1561
1730
|
*
|
|
1562
1731
|
*/
|
|
1563
1732
|
export const getLiveRunPaper = <ThrowOnError extends boolean = false>(
|
|
@@ -1590,7 +1759,8 @@ export const getLiveRunPaper = <ThrowOnError extends boolean = false>(
|
|
|
1590
1759
|
* `currency` narrows to one account; without it, every account's points come interleaved by
|
|
1591
1760
|
* time, each carrying its currency.
|
|
1592
1761
|
*
|
|
1593
|
-
* Readable by the run's owner, and by anyone if the run is `public
|
|
1762
|
+
* Readable by the run's owner, and by anyone if the run is `public` and has reached the `live`
|
|
1763
|
+
* stage.
|
|
1594
1764
|
*
|
|
1595
1765
|
*/
|
|
1596
1766
|
export const getLiveRunPaperEquity = <ThrowOnError extends boolean = false>(
|