@bitgen/sdk 1.0.7 → 1.1.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/CHANGELOG.md +18 -0
- package/README.md +5 -3
- package/dist/cjs/client.d.ts +4 -0
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +6 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/constants.d.ts +118 -0
- package/dist/cjs/constants.d.ts.map +1 -1
- package/dist/cjs/constants.js +93 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +14 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/resources/autotrading.d.ts +44 -0
- package/dist/cjs/resources/autotrading.d.ts.map +1 -0
- package/dist/cjs/resources/autotrading.js +116 -0
- package/dist/cjs/resources/autotrading.js.map +1 -0
- package/dist/cjs/resources/bot.d.ts +31 -0
- package/dist/cjs/resources/bot.d.ts.map +1 -0
- package/dist/cjs/resources/bot.js +54 -0
- package/dist/cjs/resources/bot.js.map +1 -0
- package/dist/cjs/types/autotrading.d.ts +196 -0
- package/dist/cjs/types/autotrading.d.ts.map +1 -0
- package/dist/cjs/types/autotrading.js +3 -0
- package/dist/cjs/types/autotrading.js.map +1 -0
- package/dist/cjs/types/bot.d.ts +45 -0
- package/dist/cjs/types/bot.d.ts.map +1 -0
- package/dist/cjs/types/bot.js +3 -0
- package/dist/cjs/types/bot.js.map +1 -0
- package/dist/cjs/types/index.d.ts +13 -3
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client.d.ts +4 -0
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +6 -0
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/constants.d.ts +118 -0
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.js +92 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/resources/autotrading.d.ts +44 -0
- package/dist/esm/resources/autotrading.d.ts.map +1 -0
- package/dist/esm/resources/autotrading.js +112 -0
- package/dist/esm/resources/autotrading.js.map +1 -0
- package/dist/esm/resources/bot.d.ts +31 -0
- package/dist/esm/resources/bot.d.ts.map +1 -0
- package/dist/esm/resources/bot.js +50 -0
- package/dist/esm/resources/bot.js.map +1 -0
- package/dist/esm/types/autotrading.d.ts +196 -0
- package/dist/esm/types/autotrading.d.ts.map +1 -0
- package/dist/esm/types/autotrading.js +2 -0
- package/dist/esm/types/autotrading.js.map +1 -0
- package/dist/esm/types/bot.d.ts +45 -0
- package/dist/esm/types/bot.d.ts.map +1 -0
- package/dist/esm/types/bot.js +2 -0
- package/dist/esm/types/bot.js.map +1 -0
- package/dist/esm/types/index.d.ts +13 -3
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
- package/readme/concepts.md +3 -3
- package/readme/configuration.md +2 -2
- package/readme/errors.md +1 -1
- package/readme/quick-start.md +2 -2
- package/readme/resource/autotrading.md +304 -0
- package/readme/resource/bot.md +207 -0
- package/readme/resource/custody.md +1 -1
- package/readme/resource/customer.md +1 -1
- package/readme/resource/transaction.md +1 -1
- package/readme/resource/webhooks.md +3 -1
- package/src/client.ts +6 -0
- package/src/constants.ts +131 -0
- package/src/index.ts +28 -0
- package/src/resources/autotrading.ts +132 -0
- package/src/resources/bot.ts +58 -0
- package/src/types/autotrading.ts +218 -0
- package/src/types/bot.ts +48 -0
- package/src/types/index.ts +45 -3
- package/src/version.ts +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { idOf, pathSegment } from '../utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* The technical customers the organization runs for its own account, and the modules they serve.
|
|
4
|
+
* A bot is left out of the assets under management and of the customer count, it does not appear
|
|
5
|
+
* among the customers or in the journal of transactions, and it cannot sign in.
|
|
6
|
+
*
|
|
7
|
+
* `list` and `get` answer the identity of a bot and its modules, and nothing more: the details of the
|
|
8
|
+
* account behind it are read through `client.customer`.
|
|
9
|
+
*/
|
|
10
|
+
export class BotResource {
|
|
11
|
+
http;
|
|
12
|
+
constructor(http) {
|
|
13
|
+
this.http = http;
|
|
14
|
+
}
|
|
15
|
+
/** Creates a bot in the organization — takes nothing: the platform writes the login, the name and a validated identity */
|
|
16
|
+
async create() {
|
|
17
|
+
return await this.http.post('/bot');
|
|
18
|
+
}
|
|
19
|
+
/** Bots of the organization, each with the modules it serves — closed ones with `includeClosed` */
|
|
20
|
+
async list(params = {}) {
|
|
21
|
+
return await this.http.get('/bot', { ...params });
|
|
22
|
+
}
|
|
23
|
+
/** One bot by uuid, or by model — a closed bot stays readable; the same fields as `list` */
|
|
24
|
+
async get(bot) {
|
|
25
|
+
return await this.http.get(`/bot/${this.segment(bot)}`);
|
|
26
|
+
}
|
|
27
|
+
/** Attaches the bot to a module. A module is served by one bot at most; the same bot again is a no-op */
|
|
28
|
+
async assign(bot, module) {
|
|
29
|
+
await this.http.patch(`/bot/${this.segment(bot)}/assign/${this.moduleSegment(module)}`);
|
|
30
|
+
}
|
|
31
|
+
/** Detaches the bot from a module — a module it does not serve is a no-op */
|
|
32
|
+
async detach(bot, module) {
|
|
33
|
+
await this.http.delete(`/bot/${this.segment(bot)}/assign/${this.moduleSegment(module)}`);
|
|
34
|
+
}
|
|
35
|
+
/** The modules this bot serves — not paginated: `count` is the length of the list */
|
|
36
|
+
async modules(bot) {
|
|
37
|
+
return await this.http.get(`/bot/${this.segment(bot)}/assign`);
|
|
38
|
+
}
|
|
39
|
+
/** Closes the bot. It must serve no module and hold no open position */
|
|
40
|
+
async close(bot) {
|
|
41
|
+
await this.http.delete(`/bot/${this.segment(bot)}`);
|
|
42
|
+
}
|
|
43
|
+
segment(bot) {
|
|
44
|
+
return pathSegment(idOf(bot, 'bot'), 'bot');
|
|
45
|
+
}
|
|
46
|
+
moduleSegment(module) {
|
|
47
|
+
return pathSegment(idOf(module, 'module'), 'module');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=bot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot.js","sourceRoot":"","sources":["../../../src/resources/bot.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;;;GAOG;AACH,MAAM,OAAO,WAAW;IACO;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,0HAA0H;IAC1H,KAAK,CAAC,MAAM;QACV,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACrC,CAAC;IAED,mGAAmG;IACnG,KAAK,CAAC,IAAI,CAAC,SAAwB,EAAE;QACnC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;IACnD,CAAC;IAED,4FAA4F;IAC5F,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACzD,CAAC;IAED,yGAAyG;IACzG,KAAK,CAAC,MAAM,CAAC,GAAW,EAAE,MAAoB;QAC5C,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACzF,CAAC;IAED,6EAA6E;IAC7E,KAAK,CAAC,MAAM,CAAC,GAAW,EAAE,MAAoB;QAC5C,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC1F,CAAC;IAED,qFAAqF;IACrF,KAAK,CAAC,OAAO,CAAC,GAAW;QACvB,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IAChE,CAAC;IAED,wEAAwE;IACxE,KAAK,CAAC,KAAK,CAAC,GAAW;QACrB,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACrD,CAAC;IAEO,OAAO,CAAC,GAAW;QACzB,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAA;IAC7C,CAAC;IAEO,aAAa,CAAC,MAAoB;QACxC,OAAO,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAA;IACtD,CAAC;CACF"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
export type { StrategyState, StrategyRisk, StrategyFrequency, StrategyAllocation, StrategyClosing, StrategyNotifyMode, StrategyJournalEvent, StrategyExitReason, StrategyIdleReason, } from '../constants.js';
|
|
2
|
+
import type { StrategyState, StrategyRisk, StrategyFrequency, StrategyAllocation, StrategyClosing, StrategyNotifyMode, StrategyJournalEvent, StrategyIdleReason } from '../constants.js';
|
|
3
|
+
import type { Amount, AssetInput, History, OrganizationSummary, UserSummary } from './index.js';
|
|
4
|
+
/** The guard rails of a strategy, switch by switch, with the value each one uses — percentages and EUR amounts as strings */
|
|
5
|
+
export interface StrategyGuards {
|
|
6
|
+
stopLoss: boolean;
|
|
7
|
+
/** Fall from the cost that sells, as a percentage */
|
|
8
|
+
stopLossPercent: string;
|
|
9
|
+
takeProfit: boolean;
|
|
10
|
+
/** Gain over the cost that sells, as a percentage */
|
|
11
|
+
takeProfitPercent: string;
|
|
12
|
+
trailingStop: boolean;
|
|
13
|
+
/** Fall under the highest point that sells, as a percentage */
|
|
14
|
+
trailingStopPercent: string;
|
|
15
|
+
/** Bounds the purchases — a sale is bounded by the sale minimum of the platform */
|
|
16
|
+
orderLimits: boolean;
|
|
17
|
+
/** Largest purchase, as a percentage of `capital` */
|
|
18
|
+
maxOrderPercent: string;
|
|
19
|
+
/** Floor of a purchase, in EUR */
|
|
20
|
+
minOrderAmount: string;
|
|
21
|
+
autoPause: boolean;
|
|
22
|
+
/** Daily loss that pauses, as a percentage of `capital` */
|
|
23
|
+
autoPauseLoss: string;
|
|
24
|
+
/** Losing sales in a row that pauses */
|
|
25
|
+
autoPauseStreak: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A strategy: the frame the organization sets, the state it is in, and its figures of the moment.
|
|
29
|
+
*
|
|
30
|
+
* Every EUR amount of this resource is a **string** — `capital`, `installment`, the guard rail values,
|
|
31
|
+
* `engaged`. The numbers are `trades` and `losingStreak`.
|
|
32
|
+
*/
|
|
33
|
+
export interface Strategy {
|
|
34
|
+
uuid: string;
|
|
35
|
+
/** When the frame last changed (epoch seconds) — a change of `state` leaves it as it is */
|
|
36
|
+
updatedAt: number;
|
|
37
|
+
createdAt: number;
|
|
38
|
+
state: StrategyState;
|
|
39
|
+
organization: OrganizationSummary;
|
|
40
|
+
/** The bot that holds the funds */
|
|
41
|
+
bot: UserSummary;
|
|
42
|
+
name: string;
|
|
43
|
+
/** The universe, as ISO codes — empty when the engine picks in the whole catalogue */
|
|
44
|
+
assets: string[];
|
|
45
|
+
/** Ceiling of the strategy, in EUR: never gone past, whatever the balance of the bot */
|
|
46
|
+
capital: string;
|
|
47
|
+
/** Amount of one due date, in EUR — `null` outside `DCA` */
|
|
48
|
+
installment: string | null;
|
|
49
|
+
allocation: StrategyAllocation;
|
|
50
|
+
/** Weights of the universe — an empty list while the bot spreads the capital itself */
|
|
51
|
+
allocations: Record<string, string> | [];
|
|
52
|
+
/** Whether the gains go back to work */
|
|
53
|
+
reinvest: boolean;
|
|
54
|
+
risk: StrategyRisk;
|
|
55
|
+
frequency: StrategyFrequency;
|
|
56
|
+
/** Last day of the strategy (epoch seconds) — `null` when it has none */
|
|
57
|
+
endDate: number | null;
|
|
58
|
+
closing: StrategyClosing;
|
|
59
|
+
guards: StrategyGuards;
|
|
60
|
+
notifyMode: StrategyNotifyMode;
|
|
61
|
+
/** When the strategy was closed (epoch seconds) — `null` while it is open */
|
|
62
|
+
closedAt: number | null;
|
|
63
|
+
/** When its next pass is due (epoch seconds) */
|
|
64
|
+
nextRunAt: number | null;
|
|
65
|
+
/** Why the strategy is resting — `null` when it runs normally */
|
|
66
|
+
idleReason: StrategyIdleReason | null;
|
|
67
|
+
/** Losing sales in a row, reset by a winning sale and by a resume */
|
|
68
|
+
losingStreak: number;
|
|
69
|
+
/** Gains of the sales already settled, in EUR, losses included: negative when the strategy is behind */
|
|
70
|
+
realisedGains: string;
|
|
71
|
+
/** Orders settled since the strategy started */
|
|
72
|
+
trades: number;
|
|
73
|
+
/** Cost of the positions it holds, in EUR: this is what compares to `capital` */
|
|
74
|
+
engaged: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The frame of a strategy. `update` **replaces** it field for field: a call without `assets` puts the
|
|
78
|
+
* strategy back on the whole catalogue, one without `stopLoss` switches the stop loss off — send the
|
|
79
|
+
* whole frame every time. The booleans command and the values follow: `stopLossPercent` is read when
|
|
80
|
+
* `stopLoss` is `true`.
|
|
81
|
+
*/
|
|
82
|
+
export interface StrategyInput {
|
|
83
|
+
/** 120 characters at most */
|
|
84
|
+
name: string;
|
|
85
|
+
/** Ceiling of the strategy, in EUR */
|
|
86
|
+
capital: Amount;
|
|
87
|
+
risk: StrategyRisk;
|
|
88
|
+
/** A `DCA` takes a dated pace, so `AUTO` is refused for it */
|
|
89
|
+
frequency: StrategyFrequency;
|
|
90
|
+
/** The universe, 15 at most, each asset by uuid or ISO code — absent or empty, the engine picks in the whole catalogue */
|
|
91
|
+
assets?: AssetInput[];
|
|
92
|
+
/** Amount of one due date, in EUR — required for `DCA`, ignored for the other profiles */
|
|
93
|
+
installment?: Amount;
|
|
94
|
+
/** Last day of the strategy, `YYYY-MM-DD` — read for `DCA` only */
|
|
95
|
+
endDate?: string;
|
|
96
|
+
/** Only `AUTO` is accepted: the bot alone spreads the capital over the universe */
|
|
97
|
+
allocation?: Extract<StrategyAllocation, 'AUTO'>;
|
|
98
|
+
/** `true` by default: the gains go back to work */
|
|
99
|
+
reinvest?: boolean;
|
|
100
|
+
/** `SELL_ALL` by default */
|
|
101
|
+
closing?: StrategyClosing;
|
|
102
|
+
/** `THRESHOLDS` by default */
|
|
103
|
+
notifyMode?: StrategyNotifyMode;
|
|
104
|
+
stopLoss?: boolean;
|
|
105
|
+
/** Percentage above zero and up to 100 */
|
|
106
|
+
stopLossPercent?: Amount;
|
|
107
|
+
takeProfit?: boolean;
|
|
108
|
+
/** Percentage, same shape */
|
|
109
|
+
takeProfitPercent?: Amount;
|
|
110
|
+
trailingStop?: boolean;
|
|
111
|
+
/** Percentage, same shape */
|
|
112
|
+
trailingStopPercent?: Amount;
|
|
113
|
+
/** Bounds the purchases of the strategy */
|
|
114
|
+
orderLimits?: boolean;
|
|
115
|
+
/** Largest purchase, as a percentage of `capital` */
|
|
116
|
+
maxOrderPercent?: Amount;
|
|
117
|
+
/** Floor of a purchase, in EUR */
|
|
118
|
+
minOrderAmount?: Amount;
|
|
119
|
+
autoPause?: boolean;
|
|
120
|
+
/** Daily loss that pauses, as a percentage of `capital` */
|
|
121
|
+
autoPauseLoss?: Amount;
|
|
122
|
+
/** Losing sales in a row that pauses, a whole number from one */
|
|
123
|
+
autoPauseStreak?: Amount;
|
|
124
|
+
}
|
|
125
|
+
export interface StrategyListParams {
|
|
126
|
+
offset?: number;
|
|
127
|
+
limit?: number;
|
|
128
|
+
/** Also returns the `CLOSED` strategies — default `false` */
|
|
129
|
+
includeClosed?: boolean;
|
|
130
|
+
}
|
|
131
|
+
/** One percentage per window, `null` when the window has no base to compute on */
|
|
132
|
+
export type StrategyRatios = Record<'d' | 'w' | 'm' | 'y' | 'all', number | null>;
|
|
133
|
+
/** The curve of a strategy, its performance, the same window on BTC to compare against, and the figures of the moment */
|
|
134
|
+
export interface StrategyHistory {
|
|
135
|
+
/** Value of the positions over time — each curve starts when the strategy was created */
|
|
136
|
+
history: History;
|
|
137
|
+
/** Return over each window: it accounts for what went in and out, so a purchase does not read as a gain */
|
|
138
|
+
performance: StrategyRatios;
|
|
139
|
+
/** Move of BTC over the same windows */
|
|
140
|
+
benchmark: StrategyRatios;
|
|
141
|
+
/** What the positions are worth now, in EUR: an asset with no price of its own is left out */
|
|
142
|
+
value: string;
|
|
143
|
+
/** Cost of the positions, in EUR */
|
|
144
|
+
engaged: string;
|
|
145
|
+
/** `value` less the cost of the priced positions */
|
|
146
|
+
unrealised: string;
|
|
147
|
+
realisedGains: string;
|
|
148
|
+
trades: number;
|
|
149
|
+
/** Weight of each asset of the universe, the largest first — an asset with nothing in it comes last at zero,
|
|
150
|
+
* and the shares add up to 100 as soon as a position is worth something, and are all zero when the strategy holds nothing */
|
|
151
|
+
distribution: {
|
|
152
|
+
asset: string;
|
|
153
|
+
amount: string;
|
|
154
|
+
percent: number;
|
|
155
|
+
}[];
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* One line of what a strategy did. Every line about an asset carries the position held **after** the
|
|
159
|
+
* operation; the lines that only say what the strategy became carry no quantity.
|
|
160
|
+
*/
|
|
161
|
+
export interface StrategyJournalEntry {
|
|
162
|
+
/** When the line was written (epoch seconds) */
|
|
163
|
+
date: number | null;
|
|
164
|
+
event: StrategyJournalEvent | null;
|
|
165
|
+
/**
|
|
166
|
+
* What the line is about, when it has one — `stop_loss`, `take_profit` or `trailing_stop` on a `guard`
|
|
167
|
+
* (see `StrategyExitReason`); `daily_loss` or `losing_streak` on a `paused`; `end_date` or
|
|
168
|
+
* `capital_consumed` on a `closing`; `SELL_ALL` or `KEEP` on a `closed`; an idle reason on an `idle`;
|
|
169
|
+
* `order_refused`, `sale_not_executed`, `insufficient_funds` or `daily_buy_limit_exceeded` on a `failed`
|
|
170
|
+
*/
|
|
171
|
+
reason: string | null;
|
|
172
|
+
/** ISO code of the asset of the line */
|
|
173
|
+
asset: string | null;
|
|
174
|
+
/** EUR for a `buy`, asset units for a `sell`, as a string */
|
|
175
|
+
amount: string | null;
|
|
176
|
+
/** Position held in that asset after the operation, as a string */
|
|
177
|
+
quantity: string | null;
|
|
178
|
+
/** Money of the settlement, in EUR: what a purchase cost, what a sale brought in */
|
|
179
|
+
cash: string | null;
|
|
180
|
+
/** The order behind the line — `null` on a line that has no order */
|
|
181
|
+
order: string | null;
|
|
182
|
+
}
|
|
183
|
+
/** Every strategy of the organization that is not `CLOSED`, as one position */
|
|
184
|
+
export interface AutotradingPortfolio {
|
|
185
|
+
history: History;
|
|
186
|
+
performance: StrategyRatios;
|
|
187
|
+
benchmark: StrategyRatios;
|
|
188
|
+
/** How many strategies the totals cover */
|
|
189
|
+
strategies: number;
|
|
190
|
+
/** Sum of the values of the strategies, in EUR */
|
|
191
|
+
value: string;
|
|
192
|
+
engaged: string;
|
|
193
|
+
unrealised: string;
|
|
194
|
+
realisedGains: string;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=autotrading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autotrading.d.ts","sourceRoot":"","sources":["../../../src/types/autotrading.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EACl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A;IACb,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd;iIAC6H;IAC7H,YAAY,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CACnE;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAA;IAClC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,wCAAwC;IACxC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,mEAAmE;IACnE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,oFAAoF;IACpF,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,qEAAqE;IACrE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,cAAc,CAAA;IAC3B,SAAS,EAAE,cAAc,CAAA;IACzB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAA;IAClB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autotrading.js","sourceRoot":"","sources":["../../../src/types/autotrading.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type { BotState, BotApplicationState, ExtensionState, ExtensionCategory } from '../constants.js';
|
|
2
|
+
import type { BotState, BotApplicationState, ExtensionState, ExtensionCategory } from '../constants.js';
|
|
3
|
+
/** The extension a module runs — `label` is the display name by language (`{ fr, en }`) */
|
|
4
|
+
export interface BotExtension {
|
|
5
|
+
uuid: string;
|
|
6
|
+
state: ExtensionState;
|
|
7
|
+
/** Technical name, e.g. `auto-trading` */
|
|
8
|
+
name: string;
|
|
9
|
+
category: ExtensionCategory;
|
|
10
|
+
label: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
/** A module the bot serves: an installed application of the organization and the extension it runs */
|
|
13
|
+
export interface BotApplication {
|
|
14
|
+
uuid: string;
|
|
15
|
+
/** When the module was installed (epoch seconds) */
|
|
16
|
+
createdAt: number;
|
|
17
|
+
state: BotApplicationState;
|
|
18
|
+
extension: BotExtension;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A technical customer the organization runs for its own account: an account like any other, flagged `bot`,
|
|
22
|
+
* left out of the assets under management and of the customer count, absent from the customers and from the
|
|
23
|
+
* journal of transactions, and unable to sign in.
|
|
24
|
+
*
|
|
25
|
+
* `bot.list` and `bot.get` answer the identity of the bot and its modules, and nothing more — the details of
|
|
26
|
+
* the account behind it (contact details, identity file, settings) are read through `client.customer`.
|
|
27
|
+
*/
|
|
28
|
+
export interface Bot {
|
|
29
|
+
uuid: string;
|
|
30
|
+
createdAt: number;
|
|
31
|
+
state: BotState;
|
|
32
|
+
/** `false` once the bot is closed */
|
|
33
|
+
isAvailable: boolean;
|
|
34
|
+
/** `bot_<id>@<uuid of the organization>` — rewritten when the bot is closed */
|
|
35
|
+
login: string;
|
|
36
|
+
/** The modules this bot serves, empty when it serves none */
|
|
37
|
+
applications: BotApplication[];
|
|
38
|
+
}
|
|
39
|
+
export interface BotListParams {
|
|
40
|
+
offset?: number;
|
|
41
|
+
limit?: number;
|
|
42
|
+
/** Also returns the closed bots — default `false` */
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xB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot.js","sourceRoot":"","sources":["../../../src/types/bot.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Env } from '../constants.js';
|
|
2
2
|
import type { Asset as AssetModel } from './asset.js';
|
|
3
|
+
import type { Bot, BotApplication } from './bot.js';
|
|
4
|
+
import type { Strategy } from './autotrading.js';
|
|
3
5
|
import type { Account, Customer } from './customer.js';
|
|
4
6
|
import type { OrderUser } from './trading.js';
|
|
5
7
|
/** `'production' | 'sandbox' | 'staging' | 'localhost'` — the values of `Env` */
|
|
@@ -14,7 +16,7 @@ export interface BitgenConfig {
|
|
|
14
16
|
/** Request timeout in seconds — default 30, `0` = no timeout. Expiry → `BitgenError { status: 0, code: 'request_timeout' }` */
|
|
15
17
|
timeout?: number;
|
|
16
18
|
}
|
|
17
|
-
/** `{ uuid }` — what a creation answers (`customer.create`, `bank.credit`, `staking.stake`, `webhooks.subscribe`); carries a customer's uuid where it is one */
|
|
19
|
+
/** `{ uuid }` — what a creation answers (`customer.create`, `bank.credit`, `staking.stake`, `webhooks.subscribe`, `bot.create`, `autotrading.create`); carries a customer's uuid where it is one */
|
|
18
20
|
export interface Created {
|
|
19
21
|
uuid: string;
|
|
20
22
|
}
|
|
@@ -27,7 +29,7 @@ export interface AssetRef {
|
|
|
27
29
|
/** An asset as accepted by every method expecting one: its uuid or ISO code (`Asset.ETH`), or an `Asset` / `AssetRef` returned by the SDK — its uuid is then sent */
|
|
28
30
|
export type AssetInput = string | AssetModel | AssetRef;
|
|
29
31
|
/**
|
|
30
|
-
* A user as a transaction
|
|
32
|
+
* A user as a transaction, a staking movement or a strategy references them — `{ uuid, state, login, account: { firstname, lastname, fin } }`:
|
|
31
33
|
* the customer (`owner`) or the compliance officer in charge (`assignee`). An `owner` carries the customer's uuid.
|
|
32
34
|
*/
|
|
33
35
|
export interface UserSummary {
|
|
@@ -46,7 +48,7 @@ export interface OrganizationHub {
|
|
|
46
48
|
uuid: string;
|
|
47
49
|
name: string;
|
|
48
50
|
}
|
|
49
|
-
/** An organization as a transaction
|
|
51
|
+
/** An organization as a transaction, a staking movement or a strategy references it — `hub` is only given on a transaction */
|
|
50
52
|
export interface OrganizationSummary {
|
|
51
53
|
uuid: string;
|
|
52
54
|
state: string;
|
|
@@ -59,6 +61,12 @@ export interface OrganizationSummary {
|
|
|
59
61
|
* the `user` of an `Order`, the `owner` of a `Transaction` or of a `StakingMovement`. The SDK sends the uuid.
|
|
60
62
|
*/
|
|
61
63
|
export type UserRef = string | Created | Customer | Account | UserSummary | OrderUser;
|
|
64
|
+
/** A bot as accepted by every method expecting one: its uuid, or one of the models that carry it — the `Created` of `bot.create`, or a `Bot` */
|
|
65
|
+
export type BotRef = string | Created | Bot;
|
|
66
|
+
/** A module as accepted by every method expecting one: its uuid, or a `BotApplication` returned by the SDK */
|
|
67
|
+
export type BotModuleRef = string | BotApplication;
|
|
68
|
+
/** A strategy as accepted by every method expecting one: its uuid, or one of the models that carry it — the `Created` of `autotrading.create`, or a `Strategy` */
|
|
69
|
+
export type StrategyRef = string | Created | Strategy;
|
|
62
70
|
/** An amount as accepted by the SDK — always sent to the API as a string; prefer strings, a `number` only keeps ~15 significant digits */
|
|
63
71
|
export type Amount = string | number;
|
|
64
72
|
/** Pagination query — `limit` default 10, max 50 (100 on `/transaction`) */
|
|
@@ -94,4 +102,6 @@ export type { CoreType, CoreState, CoreConfigField, Core, CoreListParams, } from
|
|
|
94
102
|
export type { StakingMovementState, StakingMovementKind, StakingPositionState, CoreRef, StakingPosition, StakingMovement, StakingOperation, StakingPortfolio, StakeParams, StakingListParams, StakingAmountParams, } from './staking.js';
|
|
95
103
|
export type { WebhookEventName, SubscriberState, WebhookType, Subscriber, WebhookSubscriptions, DeliveryLog, WebhookEvent, VerifyInput, } from './webhooks.js';
|
|
96
104
|
export type { ApikeyState, Apikey, ApikeyLog, ApikeyListParams, } from './apikeys.js';
|
|
105
|
+
export type { BotState, BotApplicationState, ExtensionState, ExtensionCategory, BotExtension, BotApplication, Bot, BotListParams, } from './bot.js';
|
|
106
|
+
export type { StrategyState, StrategyRisk, StrategyFrequency, StrategyAllocation, StrategyClosing, StrategyNotifyMode, StrategyJournalEvent, StrategyExitReason, StrategyIdleReason, StrategyGuards, Strategy, StrategyInput, StrategyListParams, StrategyRatios, StrategyHistory, StrategyJournalEntry, AutotradingPortfolio, } from './autotrading.js';
|
|
97
107
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAI7C,iFAAiF;AACjF,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,MAAM,OAAO,GAAG,CAAC,CAAA;AAEtD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,SAAS,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,+HAA+H;IAC/H,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAID,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,EAAE,KAAK,IAAI,UA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,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,WAAW,GACZ,MAAM,eAAe,CAAA;AAEtB,YAAY,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,gBAAgB,GACjB,MAAM,cAAc,CAAA;AAErB,YAAY,EACV,QAAQ,EACR,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,GAAG,EACH,aAAa,GACd,MAAM,UAAU,CAAA;AAEjB,YAAY,EACV,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,kBAAkB,CAAA"}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.0
|
|
1
|
+
export declare const VERSION = "1.1.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/esm/version.js
CHANGED
package/package.json
CHANGED
package/readme/concepts.md
CHANGED
|
@@ -27,7 +27,7 @@ The API handles crypto amounts as **strings** (up to 18 decimals): a JavaScript
|
|
|
27
27
|
- rejects, with a `TypeError` and before any request, an empty string, a negative or non-finite number, and a number that `String()` would write in exponent notation (`1e-8`, `1e21`): pass those as strings;
|
|
28
28
|
- never rounds or reformats a string: `'0.000000000000000001'` reaches the API untouched.
|
|
29
29
|
|
|
30
|
-
**Prefer strings**, even for EUR. In responses, crypto quantities are strings (`Wallet.balance`, `Order.amount`, `StakingMovement.amount`) and EUR amounts are numbers with 2 decimals (`BankAccount.balance`, `BankOperation.amount`, `StakingPortfolio.balances`).
|
|
30
|
+
**Prefer strings**, even for EUR. In responses, crypto quantities are strings (`Wallet.balance`, `Order.amount`, `StakingMovement.amount`) and EUR amounts are numbers with 2 decimals (`BankAccount.balance`, `BankOperation.amount`, `StakingPortfolio.balances`) — except in [Automated trading](resource/autotrading.md), where **every** EUR amount is a string, in and out.
|
|
31
31
|
|
|
32
32
|
**Minimums.** Purchases, sales, on-chain withdrawals and staking movements have minimums — set by BITGEN per environment, subject to change, never hard-coded in the SDK. The API's answer is the source of truth: `416 invalid_amount` for a purchase or a sale, `416 withdraw_below_minimum` for an on-chain withdrawal, `422 amount_below_minimum` for a staking movement. For staking, the provider's minimums are readable in its configuration (`client.staking.providers()`, [Staking](resource/staking.md#providers)).
|
|
33
33
|
|
|
@@ -46,11 +46,11 @@ interface Page<T> { count: number, items: T[] }
|
|
|
46
46
|
const { count, items } = await client.customer.list({ offset: 0, limit: 50 })
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
`client.core.list`
|
|
49
|
+
`client.core.list` and `client.bot.modules` are not paginated: their `count` is everything that matches. `client.autotrading.journal` is the one paginated list with a bound: it pages inside a window of ten thousand lines, and its `count` stops there ([Automated trading](resource/autotrading.md#journal)).
|
|
50
50
|
|
|
51
51
|
## Query booleans
|
|
52
52
|
|
|
53
|
-
The boolean filters of the lists — `includeClosed` (`customer.list`), `includeRevoked` (`apikeys.list`), `includeArchived` (`webhooks.list`) — are sent as `true` / `false`. The API also reads `1` / `0`, treats an absent parameter as `false`, and answers `422 invalid_<param>` for any other value: `invalid_include_closed`, `invalid_include_revoked`, `invalid_include_archived`.
|
|
53
|
+
The boolean filters of the lists — `includeClosed` (`customer.list`, `bot.list`, `autotrading.list`), `includeRevoked` (`apikeys.list`), `includeArchived` (`webhooks.list`) — are sent as `true` / `false`. The API also reads `1` / `0`, treats an absent parameter as `false`, and answers `422 invalid_<param>` for any other value: `invalid_include_closed`, `invalid_include_revoked`, `invalid_include_archived`.
|
|
54
54
|
|
|
55
55
|
## Assets
|
|
56
56
|
|
package/readme/configuration.md
CHANGED
|
@@ -6,7 +6,7 @@ A `BitgenClient` is built once per API key and reused: it holds the credentials,
|
|
|
6
6
|
import { BitgenClient, Env } from '@bitgen/sdk'
|
|
7
7
|
|
|
8
8
|
const client = new BitgenClient({
|
|
9
|
-
scope: '
|
|
9
|
+
scope: 'YOUR_ORGANIZATION_SCOPE',
|
|
10
10
|
apiKey: 'YOUR_API_KEY',
|
|
11
11
|
env: Env.PRODUCTION, // default
|
|
12
12
|
timeout: 30, // seconds, default 30
|
|
@@ -39,7 +39,7 @@ To reach the API through another hostname — a container, a tunnel — give `ho
|
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
41
|
const client = new BitgenClient({
|
|
42
|
-
scope: '
|
|
42
|
+
scope: 'YOUR_ORGANIZATION_SCOPE',
|
|
43
43
|
apiKey: 'YOUR_API_KEY',
|
|
44
44
|
host: 'my-hostname', // bare hostname: no scheme, port or path
|
|
45
45
|
port: 8080, // default 80
|
package/readme/errors.md
CHANGED
|
@@ -39,7 +39,7 @@ try {
|
|
|
39
39
|
|
|
40
40
|
## Unexpected answers
|
|
41
41
|
|
|
42
|
-
When the body is not the API's JSON error payload (proxy error page, unexpected `500`…), `code` holds the raw response text, truncated to 200 characters; the same goes for a 2xx answer that is not JSON. A `500` is not
|
|
42
|
+
When the body is not the API's JSON error payload (proxy error page, unexpected `500`…), `code` holds the raw response text, truncated to 200 characters; the same goes for a 2xx answer that is not JSON. A `500` whose body is not the API's payload did not come from the API: with a custom `host`, check that the request reaches it unchanged. Redirects are never followed: a `3xx` answer is reported as a `BitgenError`, and the key is never replayed to another host. A value the SDK enumerates (a `state`, a `mode`…) is never checked: the API may add one, the types keep it as a string ([Constants](concepts.md#constants)).
|
|
43
43
|
|
|
44
44
|
## Rejected promises
|
|
45
45
|
|
package/readme/quick-start.md
CHANGED
|
@@ -8,9 +8,9 @@ Create the client once, then run a first journey: create a customer, read their
|
|
|
8
8
|
import { BitgenClient, Env } from '@bitgen/sdk'
|
|
9
9
|
|
|
10
10
|
const client = new BitgenClient({
|
|
11
|
-
scope: '
|
|
11
|
+
scope: 'YOUR_ORGANIZATION_SCOPE', // uuid of the organization that owns the key
|
|
12
12
|
apiKey: 'YOUR_API_KEY',
|
|
13
|
-
env: Env.SANDBOX,
|
|
13
|
+
env: Env.SANDBOX, // Env.PRODUCTION by default
|
|
14
14
|
})
|
|
15
15
|
```
|
|
16
16
|
|