@qtsurfer/api-client 0.18.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 +8 -5
- package/dist/index.d.ts +265 -6
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/generated/schemas.gen.ts +302 -3
- package/src/generated/sdk.gen.ts +82 -0
- package/src/generated/types.gen.ts +245 -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
|
/**
|
|
@@ -1943,6 +1991,112 @@ export type LiveSignalPage = {
|
|
|
1943
1991
|
_links?: PublicLiveListLinks;
|
|
1944
1992
|
};
|
|
1945
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
|
+
|
|
1946
2100
|
/**
|
|
1947
2101
|
* One signal, in the same shape the real-time signal channel delivers.
|
|
1948
2102
|
*/
|
|
@@ -1964,9 +2118,12 @@ export type LiveSignal = {
|
|
|
1964
2118
|
* The parameter set in force when this signal was produced.
|
|
1965
2119
|
*/
|
|
1966
2120
|
paramsVersion?: number;
|
|
1967
|
-
type: "hint" | "info" | "marker" | "command";
|
|
1968
2121
|
/**
|
|
1969
|
-
* `
|
|
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.
|
|
1970
2127
|
*/
|
|
1971
2128
|
kind?: string | null;
|
|
1972
2129
|
/**
|
|
@@ -1977,7 +2134,10 @@ export type LiveSignal = {
|
|
|
1977
2134
|
* Time it was published — always at or after `eventTsMs`.
|
|
1978
2135
|
*/
|
|
1979
2136
|
emittedAtMs: number;
|
|
1980
|
-
|
|
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;
|
|
1981
2141
|
order?: LiveSignalOrder;
|
|
1982
2142
|
/**
|
|
1983
2143
|
* The signal's own free-form payload.
|
|
@@ -3451,7 +3611,7 @@ export type StartLiveData = {
|
|
|
3451
3611
|
|
|
3452
3612
|
export type StartLiveErrors = {
|
|
3453
3613
|
/**
|
|
3454
|
-
* 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.
|
|
3455
3615
|
*/
|
|
3456
3616
|
400: ResponseError;
|
|
3457
3617
|
/**
|
|
@@ -3645,6 +3805,10 @@ export type GetLiveRunSignalsData = {
|
|
|
3645
3805
|
*
|
|
3646
3806
|
*/
|
|
3647
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;
|
|
3648
3812
|
/**
|
|
3649
3813
|
* Continue from a previous page's `_links.next`. Takes precedence over `sinceMs`.
|
|
3650
3814
|
*/
|
|
@@ -3659,7 +3823,7 @@ export type GetLiveRunSignalsData = {
|
|
|
3659
3823
|
|
|
3660
3824
|
export type GetLiveRunSignalsErrors = {
|
|
3661
3825
|
/**
|
|
3662
|
-
* `instrument`, `sinceMs`, `limit` or `cursor` is malformed.
|
|
3826
|
+
* `instrument`, `type`, `sinceMs`, `limit` or `cursor` is malformed.
|
|
3663
3827
|
*/
|
|
3664
3828
|
400: ResponseError;
|
|
3665
3829
|
/**
|
|
@@ -3685,6 +3849,82 @@ export type GetLiveRunSignalsResponses = {
|
|
|
3685
3849
|
export type GetLiveRunSignalsResponse =
|
|
3686
3850
|
GetLiveRunSignalsResponses[keyof GetLiveRunSignalsResponses];
|
|
3687
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
|
+
|
|
3688
3928
|
export type MintLiveConnectionTokenData = {
|
|
3689
3929
|
body?: never;
|
|
3690
3930
|
path?: never;
|