@qtsurfer/api-client 0.18.0 → 0.20.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.
@@ -121,9 +121,18 @@ import type {
121
121
  UpdateLiveParamsData,
122
122
  UpdateLiveParamsResponse,
123
123
  UpdateLiveParamsError,
124
+ SendLiveCommandData,
125
+ SendLiveCommandResponse,
126
+ SendLiveCommandError,
124
127
  GetLiveRunSignalsData,
125
128
  GetLiveRunSignalsResponse,
126
129
  GetLiveRunSignalsError,
130
+ GetLiveRunPaperData,
131
+ GetLiveRunPaperResponse,
132
+ GetLiveRunPaperError,
133
+ GetLiveRunPaperEquityData,
134
+ GetLiveRunPaperEquityResponse,
135
+ GetLiveRunPaperEquityError,
127
136
  MintLiveConnectionTokenData,
128
137
  MintLiveConnectionTokenResponse,
129
138
  } from "./types.gen";
@@ -368,6 +377,10 @@ export const downloadKlines = <ThrowOnError extends boolean = false>(
368
377
  * many strategies you have. Check a specific strategy's validation with `GET
369
378
  * /strategy/{strategyId}`.
370
379
  *
380
+ * With `includeDeleted=true`, strategies you have deleted are listed too, each with the
381
+ * `deletedAt` it was deleted at — useful to keep a copy of your list in sync, telling a
382
+ * deleted strategy apart from one that never existed.
383
+ *
371
384
  */
372
385
  export const listStrategies = <ThrowOnError extends boolean = false>(
373
386
  options?: Options<ListStrategiesData, ThrowOnError>
@@ -405,6 +418,11 @@ export const listStrategies = <ThrowOnError extends boolean = false>(
405
418
  * included, is read from `GET /strategy/{strategyId}`. One place to ask, so there is no second
406
419
  * answer to keep in step.
407
420
  *
421
+ * A `200` means the source parsed and compiled, not that it will run. What only shows once the
422
+ * strategy sets up its indicators is found by `validate`: for QTScript, a window on an indicator
423
+ * name that is not registered (`window nosuch m1 { ... }`) registers, and `validate` ends `failed`
424
+ * on that line.
425
+ *
408
426
  * For **Java**, the `strategyId` is derived from what the code *means*, not from how it is
409
427
  * written. Adding a comment, inserting a blank line, re-indenting, reordering imports, or
410
428
  * moving a method around all return the **same** id — you have not created a second strategy.
@@ -970,6 +988,10 @@ export const getBacktestResult = <ThrowOnError extends boolean = false>(
970
988
  * Every dataset you have created and not deleted, most recently created first. Never a `404`
971
989
  * — an empty array if you have none, same convention as `GET /strategies`.
972
990
  *
991
+ * With `includeDeleted=true`, datasets you have deleted are listed too, each with the
992
+ * `deletedAt` it was deleted at — useful to keep a copy of your list in sync, telling a
993
+ * deleted dataset apart from one that never existed.
994
+ *
973
995
  */
974
996
  export const listDatasets = <ThrowOnError extends boolean = false>(
975
997
  options?: Options<ListDatasetsData, ThrowOnError>
@@ -1342,6 +1364,14 @@ export const getLive = <ThrowOnError extends boolean = false>(
1342
1364
  * the "Live execution" guide linked from this tag's description for the full flow (minting a
1343
1365
  * connection token, the channel and RPC method).
1344
1366
  *
1367
+ * **Paper trading.** Pass a `paper` block to have the run's hints executed in simulation from
1368
+ * its first tick, as a backtest would execute them: fills, closed trades, equity and KPIs,
1369
+ * with one simulated account per quote currency. Omitted, the run has no paper trading. It
1370
+ * takes the same economics as a backtest's `baseConfig` plus where its output goes; read it
1371
+ * back with `GET /live/{runId}/paper`. A strategy that listens to its own execution events
1372
+ * (it overrides `getExecutionCallback()`) has no other execution venue, so it cannot start
1373
+ * without a `paper` block.
1374
+ *
1345
1375
  */
1346
1376
  export const startLive = <ThrowOnError extends boolean = false>(
1347
1377
  options: Options<StartLiveData, ThrowOnError>
@@ -1394,8 +1424,9 @@ export const listLive = <ThrowOnError extends boolean = false>(
1394
1424
 
1395
1425
  /**
1396
1426
  * Browse public live runs
1397
- * Every run whose owner marked it `public` and is currently live and running — anyone's,
1398
- * yours included, and listed without revealing who owns it. Most recently started first.
1427
+ * Every run whose owner marked it `public`, that has been promoted to `live` and is running —
1428
+ * anyone's, yours included, and listed without revealing who owns it. A `public` run still in
1429
+ * its `sandbox` trial is not listed. Most recently started first.
1399
1430
  *
1400
1431
  * This is the only `Live Execution` endpoint that needs no `Authorization` header.
1401
1432
  *
@@ -1484,6 +1515,46 @@ export const updateLiveParams = <ThrowOnError extends boolean = false>(
1484
1515
  });
1485
1516
  };
1486
1517
 
1518
+ /**
1519
+ * Tell a running strategy a command
1520
+ * Tells a running strategy something **while it stays live**, without restarting it — for a strategy that
1521
+ * implements the engine's `CommandRequestHandler`. Owner only.
1522
+ *
1523
+ * A command is an event, not a stored setting: it is delivered once to every execution behind the run, at
1524
+ * the same market position, and nothing about it is written to the run's state. **It is transient** — a
1525
+ * replica that restarts replays only its recent market history, so a command from before that only reaches
1526
+ * one that was already running when it arrived. Anything the strategy needs to remember across a restart
1527
+ * belongs in a parameter (`PUT /live/{runId}/params`), which does have a stored value; a command does not.
1528
+ *
1529
+ * The command's text is a plain string; an optional `properties` object of your own choosing travels
1530
+ * alongside it. Each entry lands as a top-level entry on the `CommandRequest` the handler receives —
1531
+ * `request.get("<key>")` in Java, `$command.<key>` sugar in QTScript — no key is off limits, since the
1532
+ * command's own text is kept separately.
1533
+ *
1534
+ */
1535
+ export const sendLiveCommand = <ThrowOnError extends boolean = false>(
1536
+ options: Options<SendLiveCommandData, ThrowOnError>
1537
+ ) => {
1538
+ return (options.client ?? _heyApiClient).post<
1539
+ SendLiveCommandResponse,
1540
+ SendLiveCommandError,
1541
+ ThrowOnError
1542
+ >({
1543
+ security: [
1544
+ {
1545
+ scheme: "bearer",
1546
+ type: "http",
1547
+ },
1548
+ ],
1549
+ url: "/live/{runId}/commands",
1550
+ ...options,
1551
+ headers: {
1552
+ "Content-Type": "application/json",
1553
+ ...options?.headers,
1554
+ },
1555
+ });
1556
+ };
1557
+
1487
1558
  /**
1488
1559
  * Read a run's signals
1489
1560
  * Returns one page of the signals a run has already produced, newest-last, optionally from a
@@ -1507,8 +1578,9 @@ export const updateLiveParams = <ThrowOnError extends boolean = false>(
1507
1578
  * serving a shortened page that looks complete. Treat that as a normal outcome: read
1508
1579
  * `availableSinceMs` from the error and start again from there.
1509
1580
  *
1510
- * Readable by the run's owner, and by anyone if the run is `public` — the same rule the
1511
- * signal channel applies to a subscription.
1581
+ * Readable by the run's owner, and by anyone if the run is `public` and has reached the `live`
1582
+ * stage — the same rule the signal channel applies to a subscription. A `sandbox` run is read
1583
+ * by its owner only, whatever visibility it asked for.
1512
1584
  *
1513
1585
  */
1514
1586
  export const getLiveRunSignals = <ThrowOnError extends boolean = false>(
@@ -1530,6 +1602,75 @@ export const getLiveRunSignals = <ThrowOnError extends boolean = false>(
1530
1602
  });
1531
1603
  };
1532
1604
 
1605
+ /**
1606
+ * Read a run's paper trading
1607
+ * The run's paper trading as last recorded: one entry per simulated account (one per quote
1608
+ * currency the run trades — never added together), with its starting capital, current
1609
+ * equity, realised PnL, open positions and KPIs. The KPIs are the same a backtest reports,
1610
+ * computed over the trades closed so far.
1611
+ *
1612
+ * `equity` is the account's latest recorded value: at the last closed trade (`equityKind:
1613
+ * equity`), or the last periodic mark-to-market while positions are open (`equityKind:
1614
+ * mark`, taken every minute of market time). Until either exists the account holds its
1615
+ * starting capital.
1616
+ *
1617
+ * Readable by the run's owner, and by anyone if the run is `public` and has reached the `live`
1618
+ * stage. A run started without a `paper` block answers `404`.
1619
+ *
1620
+ */
1621
+ export const getLiveRunPaper = <ThrowOnError extends boolean = false>(
1622
+ options: Options<GetLiveRunPaperData, ThrowOnError>
1623
+ ) => {
1624
+ return (options.client ?? _heyApiClient).get<
1625
+ GetLiveRunPaperResponse,
1626
+ GetLiveRunPaperError,
1627
+ ThrowOnError
1628
+ >({
1629
+ security: [
1630
+ {
1631
+ scheme: "bearer",
1632
+ type: "http",
1633
+ },
1634
+ ],
1635
+ url: "/live/{runId}/paper",
1636
+ ...options,
1637
+ });
1638
+ };
1639
+
1640
+ /**
1641
+ * Read a run's paper equity curve
1642
+ * The run's paper equity curve, oldest first, page by page. It is kept for the life of the
1643
+ * run, so unlike signals it has no moving window. Points are `equity` at every closed trade,
1644
+ * `mark` every minute of market time while positions are open, and `gap` where the run was
1645
+ * restarted with positions open: those positions are not carried over, so the curve has no
1646
+ * value there.
1647
+ *
1648
+ * `currency` narrows to one account; without it, every account's points come interleaved by
1649
+ * time, each carrying its currency.
1650
+ *
1651
+ * Readable by the run's owner, and by anyone if the run is `public` and has reached the `live`
1652
+ * stage.
1653
+ *
1654
+ */
1655
+ export const getLiveRunPaperEquity = <ThrowOnError extends boolean = false>(
1656
+ options: Options<GetLiveRunPaperEquityData, ThrowOnError>
1657
+ ) => {
1658
+ return (options.client ?? _heyApiClient).get<
1659
+ GetLiveRunPaperEquityResponse,
1660
+ GetLiveRunPaperEquityError,
1661
+ ThrowOnError
1662
+ >({
1663
+ security: [
1664
+ {
1665
+ scheme: "bearer",
1666
+ type: "http",
1667
+ },
1668
+ ],
1669
+ url: "/live/{runId}/paper/equity",
1670
+ ...options,
1671
+ });
1672
+ };
1673
+
1533
1674
  /**
1534
1675
  * Mint a WebSocket connection token
1535
1676
  * Mints a short-lived token for the WebSocket connection used to receive a run's signals in