@qtsurfer/api-client 0.11.0 → 0.12.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 +9 -2
- package/dist/index.d.ts +223 -6
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/generated/schemas.gen.ts +278 -18
- package/src/generated/sdk.gen.ts +45 -2
- package/src/generated/types.gen.ts +210 -3
|
@@ -434,6 +434,43 @@ export type ExecuteSweepRequest = {
|
|
|
434
434
|
*/
|
|
435
435
|
minTradeFloor?: number;
|
|
436
436
|
walkForward?: WalkForwardRequest;
|
|
437
|
+
equityCurve?: EquityCurveRequest;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Requested equity-curve transform, applied server-side in a fixed pipeline order: `resample` (point count) then `differential` (encoding) then `outMode` (JSON shape) — each stage assumes the previous one already ran. A server-side size guard can still force a smaller/deflated shape above its thresholds regardless of what is requested here — see `EquityCurveMeta` for what actually happened.
|
|
442
|
+
*/
|
|
443
|
+
export type EquityCurveOptions = {
|
|
444
|
+
/**
|
|
445
|
+
* Downsample to at most this many points (extrema-preserving — the global max/min and the exact first/last point are always kept). Omit for no downsampling.
|
|
446
|
+
*/
|
|
447
|
+
resample?: number;
|
|
448
|
+
/**
|
|
449
|
+
* Delta-encode both fields from the second (post-resample) point onward.
|
|
450
|
+
*/
|
|
451
|
+
differential?: boolean;
|
|
452
|
+
/**
|
|
453
|
+
* Requested JSON shape.
|
|
454
|
+
*/
|
|
455
|
+
outMode?: EquityCurveOutMode;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Selection (`mode`/`n`/`maxPct`) plus the transform preference (`resample`/`differential`/`outMode`) applied by `GET .../equityCurve` whenever ITS OWN query params are absent, for a curve this sweep retained. The transform half never affects retention or `sweepId` — a caller can always override it per-request at read time regardless of what was submitted here.
|
|
460
|
+
*/
|
|
461
|
+
export type EquityCurveRequest = EquityCurveOptions & {
|
|
462
|
+
/**
|
|
463
|
+
* Which trials keep their per-point equity curve. `auto` retains curves only while the accumulated size stays within server limits; `topN`/`topPct` retain curves for the best-ranked trials explicitly; `none` retains no curves.
|
|
464
|
+
*/
|
|
465
|
+
mode?: "auto" | "topN" | "topPct" | "none";
|
|
466
|
+
/**
|
|
467
|
+
* Trial count to retain when mode is topN.
|
|
468
|
+
*/
|
|
469
|
+
n?: number;
|
|
470
|
+
/**
|
|
471
|
+
* Top percentage of trials to retain when mode is topPct.
|
|
472
|
+
*/
|
|
473
|
+
maxPct?: number;
|
|
437
474
|
};
|
|
438
475
|
|
|
439
476
|
/**
|
|
@@ -551,6 +588,10 @@ export type SweepRunRow = {
|
|
|
551
588
|
belowTradeFloor: boolean;
|
|
552
589
|
aborted: boolean;
|
|
553
590
|
runtimeMs: number;
|
|
591
|
+
/**
|
|
592
|
+
* Present only when this trial's curve was selected (`equityCurve.mode` was `topN`/`topPct` on the request, and this row ranked among the winners) — absent, not null, otherwise; a run that was never spilled and one that was spilled but not selected look identical here. Always a pointer today (`url` present, no inline points): a sweep's curves live in a spill store, not the response, until fetched separately. `GET` the `url` to fetch the curve itself; its own `meta` there is the real, possibly size-guarded outcome, while this outer `meta` is a raw, untransformed preview from selection time and can differ.
|
|
593
|
+
*/
|
|
594
|
+
equityCurve?: EquityCurveResult;
|
|
554
595
|
};
|
|
555
596
|
|
|
556
597
|
/**
|
|
@@ -616,6 +657,9 @@ export type SweepHeatmapCell = {
|
|
|
616
657
|
|
|
617
658
|
export type ExecuteSweepResult = {
|
|
618
659
|
sweepId: string;
|
|
660
|
+
/**
|
|
661
|
+
* The sweep's own status vocabulary — not the same set `state.status` below uses. See `state` for why.
|
|
662
|
+
*/
|
|
619
663
|
status: "RUNNING" | "COMPLETED" | "PARTIAL" | "CANCELLED";
|
|
620
664
|
objective: "sharpe" | "sortino" | "pnl" | "maxdd";
|
|
621
665
|
order: "ranked" | "natural";
|
|
@@ -647,6 +691,13 @@ export type ExecuteSweepResult = {
|
|
|
647
691
|
truncated: boolean;
|
|
648
692
|
leaderboard: Array<SweepRunRow>;
|
|
649
693
|
walkForward?: WalkForwardResult;
|
|
694
|
+
/**
|
|
695
|
+
* The same `JobState` shape a single-execute `BacktestJobResult` carries — not a sweep-specific lookalike, the actual type, so field names and timestamp formatting match exactly.
|
|
696
|
+
* `state.status` uses `JobState`'s own vocabulary (`New`/`Started`/`Completed`/ `Aborted`/`Failed`), mapped from the sweep's `status` field above rather than copying it: `PARTIAL` and `CANCELLED` both map to `Aborted`, because a sweep's `PARTIAL` is already terminal (some shards finished, some failed, nothing more is coming) unlike a single job's non-terminal `Partial`, which has no equivalent here at all.
|
|
697
|
+
* `state.completed` is real ticks processed on a plain sweep. On a `walkForward` sweep it is currently always `0` — the walk-forward fold runner was not wired to count ticks when this shipped, unlike the plain shard path.
|
|
698
|
+
* `state.size` is always `0` on every path (single execute, plain sweep, walk-forward alike) — nothing populates it anywhere yet. That is a known gap across the whole API, not a sweep-specific omission.
|
|
699
|
+
*/
|
|
700
|
+
state: JobState;
|
|
650
701
|
};
|
|
651
702
|
|
|
652
703
|
/**
|
|
@@ -812,9 +863,9 @@ export type ResultMap = {
|
|
|
812
863
|
*/
|
|
813
864
|
maxDrawdownPercent?: number;
|
|
814
865
|
/**
|
|
815
|
-
* Equity curve over the backtest.
|
|
866
|
+
* Equity curve over the backtest. `points[0]` (or `timestamps[0]`/`equities[0]` in `SHORT` mode) is an anchor at the backtest `from` with `initialCapital`; the remaining points are one sample per emitted yield, in order. Use it to plot the strategy's running equity without re-deriving it from the yield history. Always inline for a plain backtest today — never a pointer (`url`); that shape exists only for a sweep row's top-N winners.
|
|
816
867
|
*/
|
|
817
|
-
equityCurve?:
|
|
868
|
+
equityCurve?: EquityCurveResult;
|
|
818
869
|
/**
|
|
819
870
|
* Number of signals emitted during strategy execution
|
|
820
871
|
*/
|
|
@@ -855,6 +906,60 @@ export type EquityPoint = {
|
|
|
855
906
|
equity: number;
|
|
856
907
|
};
|
|
857
908
|
|
|
909
|
+
/**
|
|
910
|
+
* JSON shape for an equity curve's points. `ARRAY` is `[{timestamp, equity}, ...]`; `SHORT` is `{timestamps: [...], equities: [...]}` (parallel arrays, no repeated key text). The one schema shared by every place `outMode` appears, request or response, so the two cannot drift to different value sets.
|
|
911
|
+
*/
|
|
912
|
+
export type EquityCurveOutMode = "ARRAY" | "SHORT";
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* What the transform pipeline actually did, computed from the observed outcome — never a copy of what was requested. Lets a caller detect a forced or no-op transform (e.g. a `resample` ceiling already above the curve's size is a legal no-op, reported honestly as `resampled: false`).
|
|
916
|
+
*/
|
|
917
|
+
export type EquityCurveMeta = {
|
|
918
|
+
/**
|
|
919
|
+
* Size of the curve the transform pipeline received.
|
|
920
|
+
*/
|
|
921
|
+
inputPointCount: number;
|
|
922
|
+
/**
|
|
923
|
+
* Size after the full pipeline (resample, then differential, then outMode).
|
|
924
|
+
*/
|
|
925
|
+
outputPointCount: number;
|
|
926
|
+
/**
|
|
927
|
+
* True only if the resample stage actually changed the point count.
|
|
928
|
+
*/
|
|
929
|
+
resampled: boolean;
|
|
930
|
+
/**
|
|
931
|
+
* True only if delta-encoding actually ran. Requesting it on a curve of 0 or 1 points has nothing to encode, so it does not run even if asked.
|
|
932
|
+
*/
|
|
933
|
+
differential: boolean;
|
|
934
|
+
/**
|
|
935
|
+
* The actual JSON shape served. Present even when the points themselves are not (a pointer curve, `EquityCurveResult.url`) — a caller resolving that URL separately still needs to know how to parse what it gets back before fetching it. May override an explicit request above a server-side size threshold; this field, not the request, is the source of truth for what shape actually came back.
|
|
936
|
+
*/
|
|
937
|
+
outMode: EquityCurveOutMode;
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
/**
|
|
941
|
+
* An equity curve, shaped per `meta.outMode`: `points` when `ARRAY`, `timestamps` + `equities` (parallel arrays) when `SHORT`. Used identically wherever a curve is returned — a plain backtest's inline `equityCurve` and a sweep row's `equityCurve` are the same type. `url` is present *instead of* any points when the curve is served by pointer rather than inline (a sweep row's top-N winners only): `GET` it separately to fetch this exact same shape with the points populated.
|
|
942
|
+
*/
|
|
943
|
+
export type EquityCurveResult = {
|
|
944
|
+
meta: EquityCurveMeta;
|
|
945
|
+
/**
|
|
946
|
+
* Present when `meta.outMode` is `ARRAY` and the curve is inline (not a pointer).
|
|
947
|
+
*/
|
|
948
|
+
points?: Array<EquityPoint>;
|
|
949
|
+
/**
|
|
950
|
+
* Present when `meta.outMode` is `SHORT` and the curve is inline (not a pointer).
|
|
951
|
+
*/
|
|
952
|
+
timestamps?: Array<number>;
|
|
953
|
+
/**
|
|
954
|
+
* Present when `meta.outMode` is `SHORT` and the curve is inline (not a pointer), parallel to `timestamps` (same index, same point).
|
|
955
|
+
*/
|
|
956
|
+
equities?: Array<number>;
|
|
957
|
+
/**
|
|
958
|
+
* Present only for a sweep row's pointer curve. `GET` this to fetch the curve itself, in this exact `{points|timestamps+equities, meta}` shape — `meta` there is the real, possibly size-guarded outcome; this outer `meta` is a raw, untransformed preview from the moment the sweep selected this trial's curve, and the two can legitimately differ.
|
|
959
|
+
*/
|
|
960
|
+
url?: string;
|
|
961
|
+
};
|
|
962
|
+
|
|
858
963
|
/**
|
|
859
964
|
* Unique identifier for a compiled strategy, derived from the source itself: the same code
|
|
860
965
|
* always yields the same id, for every caller, whatever its formatting. See
|
|
@@ -863,6 +968,52 @@ export type EquityPoint = {
|
|
|
863
968
|
*/
|
|
864
969
|
export type StrategyId = string;
|
|
865
970
|
|
|
971
|
+
/**
|
|
972
|
+
* One property name `POST /strategy` could establish without constructing the strategy —
|
|
973
|
+
* either declared with `@StrategyProperty` on the compiled source, or one of the small set of
|
|
974
|
+
* base properties every strategy carries (`amnt`, `enabled`, `multiEntry`, ...).
|
|
975
|
+
*
|
|
976
|
+
* **Best-effort, not exhaustive.** A property registered through an attached risk/backtest
|
|
977
|
+
* config needs a live instance to discover and is not listed here. Use this to catch a typo'd
|
|
978
|
+
* sweep key before submitting, not as the definitive list of what a sweep will accept — a
|
|
979
|
+
* name absent from this list may still be valid.
|
|
980
|
+
*
|
|
981
|
+
*/
|
|
982
|
+
export type DeclaredProperty = {
|
|
983
|
+
/**
|
|
984
|
+
* The key a sweep or execute param map uses for this property.
|
|
985
|
+
*/
|
|
986
|
+
name: string;
|
|
987
|
+
/**
|
|
988
|
+
* Human-readable label, as declared.
|
|
989
|
+
*/
|
|
990
|
+
description?: string;
|
|
991
|
+
/**
|
|
992
|
+
* The declared default, as a string, if one was given. Absent, not null, when none was
|
|
993
|
+
* declared.
|
|
994
|
+
*
|
|
995
|
+
*/
|
|
996
|
+
defaultValue?: string;
|
|
997
|
+
/**
|
|
998
|
+
* Whether a value for this key is injected into the strategy's field (`true`) or only
|
|
999
|
+
* available through the property map (`false`).
|
|
1000
|
+
*
|
|
1001
|
+
*/
|
|
1002
|
+
reflected?: boolean;
|
|
1003
|
+
/**
|
|
1004
|
+
* Suggested sweep/range minimum, if declared. Advisory only, never validated.
|
|
1005
|
+
*/
|
|
1006
|
+
min?: number;
|
|
1007
|
+
/**
|
|
1008
|
+
* Suggested sweep/range maximum, if declared. Advisory only, never validated.
|
|
1009
|
+
*/
|
|
1010
|
+
max?: number;
|
|
1011
|
+
/**
|
|
1012
|
+
* Suggested sweep/range step, if declared. Advisory only, never validated.
|
|
1013
|
+
*/
|
|
1014
|
+
step?: number;
|
|
1015
|
+
};
|
|
1016
|
+
|
|
866
1017
|
/**
|
|
867
1018
|
* A diagnostic the engine raised while the strategy ran. Advisory: it describes something worth
|
|
868
1019
|
* knowing about how the strategy is wired, not necessarily an error.
|
|
@@ -1080,7 +1231,7 @@ export type DatasetCreated = Dataset & {
|
|
|
1080
1231
|
|
|
1081
1232
|
/**
|
|
1082
1233
|
* One successfully ingested upload. Cadence and timestamp unit are discovered from the file,
|
|
1083
|
-
* not declared by the caller
|
|
1234
|
+
* not declared by the caller.
|
|
1084
1235
|
*
|
|
1085
1236
|
*/
|
|
1086
1237
|
export type DatasetVersion = {
|
|
@@ -1478,6 +1629,12 @@ export type CompileStrategyResponses = {
|
|
|
1478
1629
|
*/
|
|
1479
1630
|
200: {
|
|
1480
1631
|
strategyId: StrategyId;
|
|
1632
|
+
/**
|
|
1633
|
+
* What could be established about this strategy's sweep-key vocabulary without
|
|
1634
|
+
* constructing it. See `DeclaredProperty` — best-effort, not exhaustive.
|
|
1635
|
+
*
|
|
1636
|
+
*/
|
|
1637
|
+
declaredProperties?: Array<DeclaredProperty>;
|
|
1481
1638
|
};
|
|
1482
1639
|
};
|
|
1483
1640
|
|
|
@@ -1891,6 +2048,55 @@ export type GetSweepSensitivityResponses = {
|
|
|
1891
2048
|
export type GetSweepSensitivityResponse =
|
|
1892
2049
|
GetSweepSensitivityResponses[keyof GetSweepSensitivityResponses];
|
|
1893
2050
|
|
|
2051
|
+
export type GetSweepRunEquityCurveData = {
|
|
2052
|
+
body?: never;
|
|
2053
|
+
path: {
|
|
2054
|
+
exchangeId: string;
|
|
2055
|
+
type: DataSourceType;
|
|
2056
|
+
requestId: string;
|
|
2057
|
+
sweepId: string;
|
|
2058
|
+
/**
|
|
2059
|
+
* The trial's `runIx`, as it appears on its leaderboard row.
|
|
2060
|
+
*/
|
|
2061
|
+
runIx: number;
|
|
2062
|
+
};
|
|
2063
|
+
query?: {
|
|
2064
|
+
/**
|
|
2065
|
+
* Requested JSON shape. Omit to use the sweep's submitted default; may be overridden either way by the server's size guard.
|
|
2066
|
+
*/
|
|
2067
|
+
outMode?: EquityCurveOutMode;
|
|
2068
|
+
/**
|
|
2069
|
+
* Downsample to at most this many points (extrema-preserving — the global max/min and the exact first/last point are always kept). Omit to use the sweep's submitted default (itself omittable, for no downsampling).
|
|
2070
|
+
*/
|
|
2071
|
+
resample?: number;
|
|
2072
|
+
/**
|
|
2073
|
+
* Delta-encode both fields from the second point onward. Omit to use the sweep's submitted default.
|
|
2074
|
+
*/
|
|
2075
|
+
differential?: boolean;
|
|
2076
|
+
};
|
|
2077
|
+
url: "/backtest/{exchangeId}/{type}/executeSweep/{requestId}/{sweepId}/runs/{runIx}/equityCurve";
|
|
2078
|
+
};
|
|
2079
|
+
|
|
2080
|
+
export type GetSweepRunEquityCurveErrors = {
|
|
2081
|
+
/**
|
|
2082
|
+
* Sweep or `runIx` not found, or that trial's curve was never selected — indistinguishable from a caller's perspective.
|
|
2083
|
+
*/
|
|
2084
|
+
404: ResponseError;
|
|
2085
|
+
};
|
|
2086
|
+
|
|
2087
|
+
export type GetSweepRunEquityCurveError =
|
|
2088
|
+
GetSweepRunEquityCurveErrors[keyof GetSweepRunEquityCurveErrors];
|
|
2089
|
+
|
|
2090
|
+
export type GetSweepRunEquityCurveResponses = {
|
|
2091
|
+
/**
|
|
2092
|
+
* The trial's equity curve, shaped per the resolved options.
|
|
2093
|
+
*/
|
|
2094
|
+
200: EquityCurveResult;
|
|
2095
|
+
};
|
|
2096
|
+
|
|
2097
|
+
export type GetSweepRunEquityCurveResponse =
|
|
2098
|
+
GetSweepRunEquityCurveResponses[keyof GetSweepRunEquityCurveResponses];
|
|
2099
|
+
|
|
1894
2100
|
export type ExecuteBacktestData = {
|
|
1895
2101
|
/**
|
|
1896
2102
|
* Execute task parameters
|
|
@@ -1907,6 +2113,7 @@ export type ExecuteBacktestData = {
|
|
|
1907
2113
|
*
|
|
1908
2114
|
*/
|
|
1909
2115
|
storeSignals?: boolean;
|
|
2116
|
+
equityCurve?: EquityCurveOptions;
|
|
1910
2117
|
};
|
|
1911
2118
|
path: {
|
|
1912
2119
|
/**
|