@qtsurfer/api-client 0.17.0 → 0.19.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 +17 -4
- package/dist/index.d.ts +340 -6
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/generated/schemas.gen.ts +387 -3
- package/src/generated/sdk.gen.ts +111 -0
- package/src/generated/types.gen.ts +319 -5
|
@@ -536,6 +536,9 @@ export type SweepBaseConfig = {
|
|
|
536
536
|
buyFeeRate?: number;
|
|
537
537
|
sellFeeRate?: number;
|
|
538
538
|
feeLeg?: "RECEIVED" | "QUOTE" | "BASE";
|
|
539
|
+
/**
|
|
540
|
+
* Share of the free balance each entry locks, in percent (0-100]. Omitted, a backtest sizes every entry with everything available.
|
|
541
|
+
*/
|
|
539
542
|
percentAmountToLock?: number;
|
|
540
543
|
};
|
|
541
544
|
|
|
@@ -1781,6 +1784,47 @@ export type StartLiveRequest = {
|
|
|
1781
1784
|
relay?: boolean;
|
|
1782
1785
|
name?: string;
|
|
1783
1786
|
description?: string;
|
|
1787
|
+
paper?: LivePaperConfig;
|
|
1788
|
+
};
|
|
1789
|
+
|
|
1790
|
+
/**
|
|
1791
|
+
* Paper trading for this run: the same economics as a backtest's `baseConfig` (same fields,
|
|
1792
|
+
* defaults and limits), plus `output`. An empty object takes every default. Each quote
|
|
1793
|
+
* currency the run trades gets its own simulated account, opened with `initialFunding` in
|
|
1794
|
+
* that currency; accounts are never added together. As returned on a run, the block is
|
|
1795
|
+
* normalised: `feeRate` is resolved into `buyFeeRate`/`sellFeeRate` and defaults are filled
|
|
1796
|
+
* in.
|
|
1797
|
+
*
|
|
1798
|
+
*/
|
|
1799
|
+
export type LivePaperConfig = {
|
|
1800
|
+
/**
|
|
1801
|
+
* Starting capital of each account, in that account's own quote currency.
|
|
1802
|
+
*/
|
|
1803
|
+
initialFunding?: number;
|
|
1804
|
+
/**
|
|
1805
|
+
* Fee rate for both sides (0.001 = 0.1%). Accepted on start; returned resolved into the two fields below.
|
|
1806
|
+
*/
|
|
1807
|
+
feeRate?: number;
|
|
1808
|
+
/**
|
|
1809
|
+
* Buy-side fee rate; overrides `feeRate`.
|
|
1810
|
+
*/
|
|
1811
|
+
buyFeeRate?: number;
|
|
1812
|
+
/**
|
|
1813
|
+
* Sell-side fee rate; overrides `feeRate`.
|
|
1814
|
+
*/
|
|
1815
|
+
sellFeeRate?: number;
|
|
1816
|
+
/**
|
|
1817
|
+
* Which asset fees are charged in. Case-insensitive on start.
|
|
1818
|
+
*/
|
|
1819
|
+
feeLeg?: "RECEIVED" | "QUOTE" | "BASE";
|
|
1820
|
+
/**
|
|
1821
|
+
* Share of the account's free balance each entry locks, in percent. Omitted, the strategy's own setting applies, and without one 10%.
|
|
1822
|
+
*/
|
|
1823
|
+
percentAmountToLock?: number;
|
|
1824
|
+
/**
|
|
1825
|
+
* `separate` keeps paper output out of the run's signals (read it with `GET /live/{runId}/paper`); `mix` also interleaves it into the run's signals as `type: paper`, right after the signal that caused it.
|
|
1826
|
+
*/
|
|
1827
|
+
output?: "separate" | "mix";
|
|
1784
1828
|
};
|
|
1785
1829
|
|
|
1786
1830
|
export type UpdateLiveRequest = {
|
|
@@ -1848,6 +1892,10 @@ export type LiveRun = {
|
|
|
1848
1892
|
gate?: {
|
|
1849
1893
|
[key: string]: unknown;
|
|
1850
1894
|
};
|
|
1895
|
+
/**
|
|
1896
|
+
* The run's paper trading configuration as accepted at start, normalised. Absent when the run has no paper trading.
|
|
1897
|
+
*/
|
|
1898
|
+
paper?: LivePaperConfig;
|
|
1851
1899
|
};
|
|
1852
1900
|
|
|
1853
1901
|
/**
|
|
@@ -1863,6 +1911,46 @@ export type LiveRunCompact = {
|
|
|
1863
1911
|
sources: Array<LiveSource>;
|
|
1864
1912
|
};
|
|
1865
1913
|
|
|
1914
|
+
/**
|
|
1915
|
+
* A run as it appears in `GET /live` — one of your own, narrower than `LiveRun` (no `params`, `paramsVersion`, `relay`, or `gate`), since listing stays cheap regardless of how many runs you have. Check a specific run's full state with `GET /strategy/{strategyId}/live`.
|
|
1916
|
+
*/
|
|
1917
|
+
export type LiveRunSummary = {
|
|
1918
|
+
strategyId: StrategyId;
|
|
1919
|
+
/**
|
|
1920
|
+
* This run's own id — its canonical identity for `PATCH`/`PUT .../params` and for `GET /live/public`.
|
|
1921
|
+
*/
|
|
1922
|
+
runId: string;
|
|
1923
|
+
name?: string;
|
|
1924
|
+
description?: string;
|
|
1925
|
+
visibility: "private" | "public";
|
|
1926
|
+
/**
|
|
1927
|
+
* A new run always starts `SANDBOX` — a trial run compared against a second execution for agreement — and moves to `LIVE` once it passes.
|
|
1928
|
+
*/
|
|
1929
|
+
stage: "SANDBOX" | "LIVE";
|
|
1930
|
+
/**
|
|
1931
|
+
* `STARTING` until first observed running; otherwise the runner's own reported state (e.g. `RUNNING`).
|
|
1932
|
+
*/
|
|
1933
|
+
state: string;
|
|
1934
|
+
/**
|
|
1935
|
+
* What you last asked for. `state` can lag this briefly after `DELETE`.
|
|
1936
|
+
*/
|
|
1937
|
+
desired: "RUNNING" | "STOPPED";
|
|
1938
|
+
sources: Array<LiveSource>;
|
|
1939
|
+
/**
|
|
1940
|
+
* Epoch milliseconds this run was started.
|
|
1941
|
+
*/
|
|
1942
|
+
createdAtMs: number;
|
|
1943
|
+
/**
|
|
1944
|
+
* Epoch milliseconds.
|
|
1945
|
+
*/
|
|
1946
|
+
startedAtMs: number;
|
|
1947
|
+
};
|
|
1948
|
+
|
|
1949
|
+
export type LiveListResponse = {
|
|
1950
|
+
runs: Array<LiveRunSummary>;
|
|
1951
|
+
_links?: PublicLiveListLinks;
|
|
1952
|
+
};
|
|
1953
|
+
|
|
1866
1954
|
/**
|
|
1867
1955
|
* A run as it appears in `GET /live/public` — never reveals who owns it or which strategy it runs.
|
|
1868
1956
|
*/
|
|
@@ -1903,6 +1991,112 @@ export type LiveSignalPage = {
|
|
|
1903
1991
|
_links?: PublicLiveListLinks;
|
|
1904
1992
|
};
|
|
1905
1993
|
|
|
1994
|
+
export type LivePaper = {
|
|
1995
|
+
runId: string;
|
|
1996
|
+
stage: "SANDBOX" | "LIVE";
|
|
1997
|
+
accounts: Array<LivePaperAccount>;
|
|
1998
|
+
};
|
|
1999
|
+
|
|
2000
|
+
/**
|
|
2001
|
+
* One simulated account — one per quote currency the run trades.
|
|
2002
|
+
*/
|
|
2003
|
+
export type LivePaperAccount = {
|
|
2004
|
+
/**
|
|
2005
|
+
* The account's quote currency; every amount below is in it.
|
|
2006
|
+
*/
|
|
2007
|
+
currency: string;
|
|
2008
|
+
initialFunding: number;
|
|
2009
|
+
/**
|
|
2010
|
+
* Latest recorded equity — see `equityKind`.
|
|
2011
|
+
*/
|
|
2012
|
+
equity: number;
|
|
2013
|
+
/**
|
|
2014
|
+
* Market time of that value. Absent while the account holds its starting capital.
|
|
2015
|
+
*/
|
|
2016
|
+
equityAtMs?: number;
|
|
2017
|
+
/**
|
|
2018
|
+
* `equity` at a closed trade, `mark` at a periodic mark-to-market (includes open positions at market price).
|
|
2019
|
+
*/
|
|
2020
|
+
equityKind?: "equity" | "mark";
|
|
2021
|
+
/**
|
|
2022
|
+
* Sum of the PnL of the closed trades.
|
|
2023
|
+
*/
|
|
2024
|
+
realisedPnl: number;
|
|
2025
|
+
/**
|
|
2026
|
+
* Closed trades.
|
|
2027
|
+
*/
|
|
2028
|
+
trades: number;
|
|
2029
|
+
/**
|
|
2030
|
+
* Times open positions were lost because the run was restarted with them open.
|
|
2031
|
+
*/
|
|
2032
|
+
gaps: number;
|
|
2033
|
+
openPositions: Array<LivePaperPosition>;
|
|
2034
|
+
kpi?: LivePaperKpi;
|
|
2035
|
+
};
|
|
2036
|
+
|
|
2037
|
+
export type LivePaperPosition = {
|
|
2038
|
+
instrument: string;
|
|
2039
|
+
/**
|
|
2040
|
+
* Amount held, in the base asset.
|
|
2041
|
+
*/
|
|
2042
|
+
base: number;
|
|
2043
|
+
/**
|
|
2044
|
+
* What it cost, in the account's currency.
|
|
2045
|
+
*/
|
|
2046
|
+
cost: number;
|
|
2047
|
+
};
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* The same KPIs a backtest reports, over the trades closed so far. Absent until the first closed trade is recorded.
|
|
2051
|
+
*/
|
|
2052
|
+
export type LivePaperKpi = {
|
|
2053
|
+
totalTrades?: number;
|
|
2054
|
+
winCount?: number;
|
|
2055
|
+
lossCount?: number;
|
|
2056
|
+
/**
|
|
2057
|
+
* Ratio (0.5 = half the trades won).
|
|
2058
|
+
*/
|
|
2059
|
+
winRate?: number;
|
|
2060
|
+
pnlTotal?: number;
|
|
2061
|
+
/**
|
|
2062
|
+
* Percent of `initialFunding` (0-100 scale).
|
|
2063
|
+
*/
|
|
2064
|
+
pnlTotalPercent?: number;
|
|
2065
|
+
sharpeRatio?: number | null;
|
|
2066
|
+
sortinoRatio?: number | null;
|
|
2067
|
+
/**
|
|
2068
|
+
* Ratio (0.15 for 15%).
|
|
2069
|
+
*/
|
|
2070
|
+
cagr?: number | null;
|
|
2071
|
+
maxDrawdown?: number;
|
|
2072
|
+
/**
|
|
2073
|
+
* Percent (0-100 scale).
|
|
2074
|
+
*/
|
|
2075
|
+
maxDrawdownPercent?: number;
|
|
2076
|
+
};
|
|
2077
|
+
|
|
2078
|
+
export type LivePaperEquityPage = {
|
|
2079
|
+
points: Array<LivePaperEquityPoint>;
|
|
2080
|
+
_links?: {
|
|
2081
|
+
next?: {
|
|
2082
|
+
href?: string;
|
|
2083
|
+
};
|
|
2084
|
+
};
|
|
2085
|
+
};
|
|
2086
|
+
|
|
2087
|
+
export type LivePaperEquityPoint = {
|
|
2088
|
+
currency: string;
|
|
2089
|
+
kind: "equity" | "mark" | "gap";
|
|
2090
|
+
/**
|
|
2091
|
+
* Market time of the point.
|
|
2092
|
+
*/
|
|
2093
|
+
eventTsMs: number;
|
|
2094
|
+
/**
|
|
2095
|
+
* Absent on a `gap`.
|
|
2096
|
+
*/
|
|
2097
|
+
equity?: number;
|
|
2098
|
+
};
|
|
2099
|
+
|
|
1906
2100
|
/**
|
|
1907
2101
|
* One signal, in the same shape the real-time signal channel delivers.
|
|
1908
2102
|
*/
|
|
@@ -1924,9 +2118,12 @@ export type LiveSignal = {
|
|
|
1924
2118
|
* The parameter set in force when this signal was produced.
|
|
1925
2119
|
*/
|
|
1926
2120
|
paramsVersion?: number;
|
|
1927
|
-
type: "hint" | "info" | "marker" | "command";
|
|
1928
2121
|
/**
|
|
1929
|
-
* `
|
|
2122
|
+
* `paper` items appear only for a run whose `paper.output` is `mix`; they are not relayed over the WebSocket channel.
|
|
2123
|
+
*/
|
|
2124
|
+
type: "hint" | "info" | "marker" | "command" | "paper";
|
|
2125
|
+
/**
|
|
2126
|
+
* `BUY`/`SELL` for a `hint`, the command name for a `command`; for `paper`, what the item is: `fill`, `trade`, `equity`, `mark`, `kpi` or `gap`. Absent otherwise.
|
|
1930
2127
|
*/
|
|
1931
2128
|
kind?: string | null;
|
|
1932
2129
|
/**
|
|
@@ -1937,7 +2134,10 @@ export type LiveSignal = {
|
|
|
1937
2134
|
* Time it was published — always at or after `eventTsMs`.
|
|
1938
2135
|
*/
|
|
1939
2136
|
emittedAtMs: number;
|
|
1940
|
-
|
|
2137
|
+
/**
|
|
2138
|
+
* The instrument the signal is about. `null` only for a `paper` item about a whole account (`equity`, `mark`, `kpi`), whose `data.currency` names the account.
|
|
2139
|
+
*/
|
|
2140
|
+
instrument: LiveSignalInstrument | null;
|
|
1941
2141
|
order?: LiveSignalOrder;
|
|
1942
2142
|
/**
|
|
1943
2143
|
* The signal's own free-form payload.
|
|
@@ -3411,7 +3611,7 @@ export type StartLiveData = {
|
|
|
3411
3611
|
|
|
3412
3612
|
export type StartLiveErrors = {
|
|
3413
3613
|
/**
|
|
3414
|
-
* Malformed `sources` (not exactly one entry, missing field, unsupported `type`),
|
|
3614
|
+
* Malformed `sources` (not exactly one entry, missing field, unsupported `type`), an invalid `visibility`, an invalid `paper` block (an unknown field, a wrong type or an out-of-range value), or no `paper` block for a strategy that listens to its own execution events.
|
|
3415
3615
|
*/
|
|
3416
3616
|
400: ResponseError;
|
|
3417
3617
|
/**
|
|
@@ -3442,6 +3642,40 @@ export type StartLiveResponses = {
|
|
|
3442
3642
|
|
|
3443
3643
|
export type StartLiveResponse = StartLiveResponses[keyof StartLiveResponses];
|
|
3444
3644
|
|
|
3645
|
+
export type ListLiveData = {
|
|
3646
|
+
body?: never;
|
|
3647
|
+
path?: never;
|
|
3648
|
+
query?: {
|
|
3649
|
+
/**
|
|
3650
|
+
* The `runId` from a previous page's `_links.next.href`. Omit for the first page.
|
|
3651
|
+
*/
|
|
3652
|
+
cursor?: string;
|
|
3653
|
+
/**
|
|
3654
|
+
* Page size. Larger values are capped, not rejected.
|
|
3655
|
+
*/
|
|
3656
|
+
limit?: number;
|
|
3657
|
+
};
|
|
3658
|
+
url: "/live";
|
|
3659
|
+
};
|
|
3660
|
+
|
|
3661
|
+
export type ListLiveErrors = {
|
|
3662
|
+
/**
|
|
3663
|
+
* An invalid `cursor` or `limit`.
|
|
3664
|
+
*/
|
|
3665
|
+
400: ResponseError;
|
|
3666
|
+
};
|
|
3667
|
+
|
|
3668
|
+
export type ListLiveError = ListLiveErrors[keyof ListLiveErrors];
|
|
3669
|
+
|
|
3670
|
+
export type ListLiveResponses = {
|
|
3671
|
+
/**
|
|
3672
|
+
* A page of your own runs
|
|
3673
|
+
*/
|
|
3674
|
+
200: LiveListResponse;
|
|
3675
|
+
};
|
|
3676
|
+
|
|
3677
|
+
export type ListLiveResponse = ListLiveResponses[keyof ListLiveResponses];
|
|
3678
|
+
|
|
3445
3679
|
export type ListPublicLiveData = {
|
|
3446
3680
|
body?: never;
|
|
3447
3681
|
path?: never;
|
|
@@ -3571,6 +3805,10 @@ export type GetLiveRunSignalsData = {
|
|
|
3571
3805
|
*
|
|
3572
3806
|
*/
|
|
3573
3807
|
instrument?: string;
|
|
3808
|
+
/**
|
|
3809
|
+
* Narrow to one or more signal types, comma-separated (`hint`, `info`, `marker`, `command`, `paper`). Combines with `instrument`.
|
|
3810
|
+
*/
|
|
3811
|
+
type?: string;
|
|
3574
3812
|
/**
|
|
3575
3813
|
* Continue from a previous page's `_links.next`. Takes precedence over `sinceMs`.
|
|
3576
3814
|
*/
|
|
@@ -3585,7 +3823,7 @@ export type GetLiveRunSignalsData = {
|
|
|
3585
3823
|
|
|
3586
3824
|
export type GetLiveRunSignalsErrors = {
|
|
3587
3825
|
/**
|
|
3588
|
-
* `instrument`, `sinceMs`, `limit` or `cursor` is malformed.
|
|
3826
|
+
* `instrument`, `type`, `sinceMs`, `limit` or `cursor` is malformed.
|
|
3589
3827
|
*/
|
|
3590
3828
|
400: ResponseError;
|
|
3591
3829
|
/**
|
|
@@ -3611,6 +3849,82 @@ export type GetLiveRunSignalsResponses = {
|
|
|
3611
3849
|
export type GetLiveRunSignalsResponse =
|
|
3612
3850
|
GetLiveRunSignalsResponses[keyof GetLiveRunSignalsResponses];
|
|
3613
3851
|
|
|
3852
|
+
export type GetLiveRunPaperData = {
|
|
3853
|
+
body?: never;
|
|
3854
|
+
path: {
|
|
3855
|
+
runId: string;
|
|
3856
|
+
};
|
|
3857
|
+
query?: never;
|
|
3858
|
+
url: "/live/{runId}/paper";
|
|
3859
|
+
};
|
|
3860
|
+
|
|
3861
|
+
export type GetLiveRunPaperErrors = {
|
|
3862
|
+
/**
|
|
3863
|
+
* No such run, not one you may read, or a run without paper trading.
|
|
3864
|
+
*/
|
|
3865
|
+
404: ResponseError;
|
|
3866
|
+
};
|
|
3867
|
+
|
|
3868
|
+
export type GetLiveRunPaperError =
|
|
3869
|
+
GetLiveRunPaperErrors[keyof GetLiveRunPaperErrors];
|
|
3870
|
+
|
|
3871
|
+
export type GetLiveRunPaperResponses = {
|
|
3872
|
+
/**
|
|
3873
|
+
* The run's paper accounts
|
|
3874
|
+
*/
|
|
3875
|
+
200: LivePaper;
|
|
3876
|
+
};
|
|
3877
|
+
|
|
3878
|
+
export type GetLiveRunPaperResponse =
|
|
3879
|
+
GetLiveRunPaperResponses[keyof GetLiveRunPaperResponses];
|
|
3880
|
+
|
|
3881
|
+
export type GetLiveRunPaperEquityData = {
|
|
3882
|
+
body?: never;
|
|
3883
|
+
path: {
|
|
3884
|
+
runId: string;
|
|
3885
|
+
};
|
|
3886
|
+
query?: {
|
|
3887
|
+
/**
|
|
3888
|
+
* One account's quote currency, e.g. `USDT`.
|
|
3889
|
+
*/
|
|
3890
|
+
currency?: string;
|
|
3891
|
+
/**
|
|
3892
|
+
* Start from this market time (epoch ms). Ignored when `cursor` is given.
|
|
3893
|
+
*/
|
|
3894
|
+
sinceMs?: number;
|
|
3895
|
+
/**
|
|
3896
|
+
* Continue from a previous page's `_links.next`.
|
|
3897
|
+
*/
|
|
3898
|
+
cursor?: string;
|
|
3899
|
+
limit?: number;
|
|
3900
|
+
};
|
|
3901
|
+
url: "/live/{runId}/paper/equity";
|
|
3902
|
+
};
|
|
3903
|
+
|
|
3904
|
+
export type GetLiveRunPaperEquityErrors = {
|
|
3905
|
+
/**
|
|
3906
|
+
* `sinceMs`, `limit` or `cursor` is malformed.
|
|
3907
|
+
*/
|
|
3908
|
+
400: ResponseError;
|
|
3909
|
+
/**
|
|
3910
|
+
* No such run, not one you may read, or a run without paper trading.
|
|
3911
|
+
*/
|
|
3912
|
+
404: ResponseError;
|
|
3913
|
+
};
|
|
3914
|
+
|
|
3915
|
+
export type GetLiveRunPaperEquityError =
|
|
3916
|
+
GetLiveRunPaperEquityErrors[keyof GetLiveRunPaperEquityErrors];
|
|
3917
|
+
|
|
3918
|
+
export type GetLiveRunPaperEquityResponses = {
|
|
3919
|
+
/**
|
|
3920
|
+
* One page of the curve
|
|
3921
|
+
*/
|
|
3922
|
+
200: LivePaperEquityPage;
|
|
3923
|
+
};
|
|
3924
|
+
|
|
3925
|
+
export type GetLiveRunPaperEquityResponse =
|
|
3926
|
+
GetLiveRunPaperEquityResponses[keyof GetLiveRunPaperEquityResponses];
|
|
3927
|
+
|
|
3614
3928
|
export type MintLiveConnectionTokenData = {
|
|
3615
3929
|
body?: never;
|
|
3616
3930
|
path?: never;
|