@toromarket/cli 0.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/dist/index.cjs +578 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +555 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/commands/index.ts
|
|
27
|
+
var import_chalk = __toESM(require("chalk"), 1);
|
|
28
|
+
var import_commander = require("commander");
|
|
29
|
+
var import_sdk2 = require("@toromarket/sdk");
|
|
30
|
+
|
|
31
|
+
// src/client.ts
|
|
32
|
+
var import_sdk = require("@toromarket/sdk");
|
|
33
|
+
|
|
34
|
+
// src/config/credentials.ts
|
|
35
|
+
var import_promises = require("fs/promises");
|
|
36
|
+
var import_node_os = require("os");
|
|
37
|
+
var import_node_path = require("path");
|
|
38
|
+
var credentialsPath = (0, import_node_path.join)((0, import_node_os.homedir)(), ".toromarket", "credentials.json");
|
|
39
|
+
function getCredentialsPath() {
|
|
40
|
+
return credentialsPath;
|
|
41
|
+
}
|
|
42
|
+
async function loadCredentials() {
|
|
43
|
+
try {
|
|
44
|
+
const raw = await (0, import_promises.readFile)(credentialsPath, "utf8");
|
|
45
|
+
return JSON.parse(raw);
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function saveCredentials(credentials) {
|
|
51
|
+
await (0, import_promises.mkdir)((0, import_node_path.dirname)(credentialsPath), { recursive: true, mode: 448 });
|
|
52
|
+
await (0, import_promises.writeFile)(credentialsPath, JSON.stringify(credentials, null, 2), { encoding: "utf8", mode: 384 });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/client.ts
|
|
56
|
+
async function createClient() {
|
|
57
|
+
const baseUrl = process.env.TOROMARKET_BASE_URL ?? "https://api.toromarket.io";
|
|
58
|
+
const creds = await loadCredentials();
|
|
59
|
+
return new import_sdk.ToromarketClient({
|
|
60
|
+
baseUrl,
|
|
61
|
+
...creds?.token ? { token: creds.token } : {}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/commands/index.ts
|
|
66
|
+
function print(data) {
|
|
67
|
+
const normalized = data === void 0 ? { ok: true } : data;
|
|
68
|
+
process.stdout.write(`${JSON.stringify(normalized, null, 2)}
|
|
69
|
+
`);
|
|
70
|
+
}
|
|
71
|
+
function printError(error) {
|
|
72
|
+
if (error instanceof import_sdk2.ToromarketError) {
|
|
73
|
+
const payload = {
|
|
74
|
+
error: error.message,
|
|
75
|
+
statusCode: error.statusCode
|
|
76
|
+
};
|
|
77
|
+
if (error.code) {
|
|
78
|
+
payload.code = error.code;
|
|
79
|
+
}
|
|
80
|
+
process.stderr.write(`${import_chalk.default.red("Error:")} ${JSON.stringify(payload, null, 2)}
|
|
81
|
+
`);
|
|
82
|
+
} else {
|
|
83
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
84
|
+
process.stderr.write(`${import_chalk.default.red("Error:")} ${msg}
|
|
85
|
+
`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async function withClient(action) {
|
|
89
|
+
const program = new import_commander.Command();
|
|
90
|
+
const client = await createClient();
|
|
91
|
+
try {
|
|
92
|
+
await action(program, client);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
printError(error);
|
|
95
|
+
process.exitCode = 1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function createProgram() {
|
|
99
|
+
const program = new import_commander.Command();
|
|
100
|
+
program.name("toromarket").description("Toromarket CLI").version("0.1.0");
|
|
101
|
+
program.command("register").requiredOption("--email <email>").requiredOption("--username <username>").requiredOption("--password <password>").action(async (options) => {
|
|
102
|
+
await withClient(async (_, client) => {
|
|
103
|
+
const auth = await client.auth.register(options);
|
|
104
|
+
await saveAuth(auth, options.email);
|
|
105
|
+
print(auth);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
program.command("login").requiredOption("--email <email>").requiredOption("--password <password>").action(async (options) => {
|
|
109
|
+
await withClient(async (_, client) => {
|
|
110
|
+
const auth = await client.auth.login(options);
|
|
111
|
+
await saveAuth(auth, options.email);
|
|
112
|
+
print(auth);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
const markets = program.command("markets").description("Prediction markets");
|
|
116
|
+
markets.command("list").action(async () => {
|
|
117
|
+
await withClient(async (_, client) => {
|
|
118
|
+
print(await client.predictions.listMarkets());
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
markets.command("get").argument("<marketId>").action(async (marketId) => {
|
|
122
|
+
await withClient(async (_, client) => {
|
|
123
|
+
print(await client.predictions.getMarket(marketId));
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
markets.command("trades").argument("<marketId>").option("--limit <limit>").option("--offset <offset>").action(async (marketId, options) => {
|
|
127
|
+
await withClient(async (_, client) => {
|
|
128
|
+
print(await client.predictions.getMarketTrades(marketId, {
|
|
129
|
+
...options.limit ? { limit: Number(options.limit) } : {},
|
|
130
|
+
...options.offset ? { offset: Number(options.offset) } : {}
|
|
131
|
+
}));
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
markets.command("positions").argument("<marketId>").action(async (marketId) => {
|
|
135
|
+
await withClient(async (_, client) => {
|
|
136
|
+
print(await client.predictions.getMarketPositions(marketId));
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
markets.command("orders").argument("<marketId>").action(async (marketId) => {
|
|
140
|
+
await withClient(async (_, client) => {
|
|
141
|
+
print(await client.predictions.getMarketOrders(marketId));
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
program.command("buy").argument("<marketId>").requiredOption("--outcome-id <outcomeId>").requiredOption("--shares <shares>").requiredOption("--price <price>").action(async (marketId, options) => {
|
|
145
|
+
await placePredictionOrder(marketId, "BUY", options);
|
|
146
|
+
});
|
|
147
|
+
program.command("sell").argument("<marketId>").requiredOption("--outcome-id <outcomeId>").requiredOption("--shares <shares>").requiredOption("--price <price>").action(async (marketId, options) => {
|
|
148
|
+
await placePredictionOrder(marketId, "SELL", options);
|
|
149
|
+
});
|
|
150
|
+
const orders = program.command("orders").description("Prediction orders");
|
|
151
|
+
orders.command("cancel").argument("<marketId>").argument("<orderId>").action(async (marketId, orderId) => {
|
|
152
|
+
await withClient(async (_, client) => {
|
|
153
|
+
print(await client.predictions.cancelOrder(marketId, orderId));
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
const crypto = program.command("crypto").description("Crypto markets");
|
|
157
|
+
crypto.command("list").action(async () => {
|
|
158
|
+
await withClient(async (_, client) => {
|
|
159
|
+
print(await client.markets.list());
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
crypto.command("buy").argument("<symbol>").requiredOption("--quantity <quantity>").action(async (symbol, options) => {
|
|
163
|
+
await tradeCrypto(symbol, "BUY", options.quantity);
|
|
164
|
+
});
|
|
165
|
+
crypto.command("sell").argument("<symbol>").requiredOption("--quantity <quantity>").action(async (symbol, options) => {
|
|
166
|
+
await tradeCrypto(symbol, "SELL", options.quantity);
|
|
167
|
+
});
|
|
168
|
+
crypto.command("get").argument("<symbol>").action(async (symbol) => {
|
|
169
|
+
await withClient(async (_, client) => {
|
|
170
|
+
print(await client.markets.get(symbol));
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
crypto.command("klines").argument("<symbol>").option("--interval <interval>", "e.g. 1h, 4h, 1d").option("--limit <limit>").action(async (symbol, options) => {
|
|
174
|
+
await withClient(async (_, client) => {
|
|
175
|
+
print(await client.markets.getKlines(symbol, {
|
|
176
|
+
...options.interval ? { interval: options.interval } : {},
|
|
177
|
+
...options.limit ? { limit: Number(options.limit) } : {}
|
|
178
|
+
}));
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
crypto.command("movers").action(async () => {
|
|
182
|
+
await withClient(async (_, client) => {
|
|
183
|
+
print(await client.markets.getMovers());
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
program.command("portfolio").action(async () => {
|
|
187
|
+
await withClient(async (_, client) => {
|
|
188
|
+
print(await client.portfolio.get());
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
program.command("positions").action(async () => {
|
|
192
|
+
await withClient(async (_, client) => {
|
|
193
|
+
print(await client.predictions.getPositions());
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
program.command("balance").action(async () => {
|
|
197
|
+
await withClient(async (_, client) => {
|
|
198
|
+
const portfolio = await client.portfolio.get();
|
|
199
|
+
print({ balance: portfolio.balance ?? null, totalValue: portfolio.totalValue ?? null });
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
program.command("trades").option("--limit <limit>").option("--offset <offset>").action(async (options) => {
|
|
203
|
+
await withClient(async (_, client) => {
|
|
204
|
+
print(await client.portfolio.getTrades({
|
|
205
|
+
...options.limit ? { limit: Number(options.limit) } : {},
|
|
206
|
+
...options.offset ? { offset: Number(options.offset) } : {}
|
|
207
|
+
}));
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
program.command("open-orders").action(async () => {
|
|
211
|
+
await withClient(async (_, client) => {
|
|
212
|
+
print(await client.portfolio.getOpenOrders());
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
program.command("portfolio-metrics").action(async () => {
|
|
216
|
+
await withClient(async (_, client) => {
|
|
217
|
+
print(await client.portfolio.getMetrics());
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
program.command("comment").argument("<marketId>").argument("<content>").action(async (marketId, content) => {
|
|
221
|
+
await withClient(async (_, client) => {
|
|
222
|
+
print(await client.chat.post(`PRED-${marketId}`, { content }));
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
const funds = program.command("funds").description("Fund actions");
|
|
226
|
+
funds.command("list").action(async () => {
|
|
227
|
+
await withClient(async (_, client) => {
|
|
228
|
+
print(await client.funds.list());
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
funds.command("join").argument("<fundId>").requiredOption("--stake <stake>").option("--invite-code <inviteCode>").action(async (fundId, options) => {
|
|
232
|
+
await withClient(async (_, client) => {
|
|
233
|
+
print(
|
|
234
|
+
await client.funds.join(fundId, {
|
|
235
|
+
stake: Number(options.stake),
|
|
236
|
+
...options.inviteCode ? { inviteCode: options.inviteCode } : {}
|
|
237
|
+
})
|
|
238
|
+
);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
funds.command("create").requiredOption("--name <name>").requiredOption("--description <description>").requiredOption("--initial-stake <initialStake>").option("--invite-only").option("--min-stake <minStakeToJoin>").option("--invite-code <inviteCode>").action(
|
|
242
|
+
async (options) => {
|
|
243
|
+
await withClient(async (_, client) => {
|
|
244
|
+
print(
|
|
245
|
+
await client.funds.create({
|
|
246
|
+
name: options.name,
|
|
247
|
+
description: options.description,
|
|
248
|
+
initialStake: Number(options.initialStake),
|
|
249
|
+
...options.inviteOnly ? { inviteOnly: true } : {},
|
|
250
|
+
...options.minStake ? { minStakeToJoin: Number(options.minStake) } : {},
|
|
251
|
+
...options.inviteCode ? { inviteCode: options.inviteCode } : {}
|
|
252
|
+
})
|
|
253
|
+
);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
funds.command("message").argument("<fundId>").argument("<content>").action(async (fundId, content) => {
|
|
258
|
+
await withClient(async (_, client) => {
|
|
259
|
+
print(await client.funds.chat(fundId, { content }));
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
funds.command("members").argument("<fundId>").action(async (fundId) => {
|
|
263
|
+
await withClient(async (_, client) => {
|
|
264
|
+
print(await client.funds.members(fundId));
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
funds.command("set-role").argument("<fundId>").requiredOption("--user-id <targetUserId>").requiredOption("--role <role>").action(
|
|
268
|
+
async (fundId, options) => {
|
|
269
|
+
await withClient(async (_, client) => {
|
|
270
|
+
print(
|
|
271
|
+
await client.funds.updateMemberRole(fundId, {
|
|
272
|
+
targetUserId: options.targetUserId,
|
|
273
|
+
role: options.role
|
|
274
|
+
})
|
|
275
|
+
);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
funds.command("remove-member").argument("<fundId>").requiredOption("--user-id <userId>").action(async (fundId, options) => {
|
|
280
|
+
await withClient(async (_, client) => {
|
|
281
|
+
print(await client.funds.removeMember(fundId, options.userId));
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
funds.command("transfer-ownership").argument("<fundId>").requiredOption("--target-user-id <targetUserId>").action(async (fundId, options) => {
|
|
285
|
+
await withClient(async (_, client) => {
|
|
286
|
+
print(await client.funds.transferOwnership(fundId, { targetUserId: options.targetUserId }));
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
funds.command("leave").argument("<fundId>").action(async (fundId) => {
|
|
290
|
+
await withClient(async (_, client) => {
|
|
291
|
+
print(await client.funds.leave(fundId));
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
funds.command("chat").argument("<fundId>").option("--cursor <cursor>").option("--limit <limit>").action(async (fundId, options) => {
|
|
295
|
+
await withClient(async (_, client) => {
|
|
296
|
+
print(
|
|
297
|
+
await client.funds.chatHistory(fundId, {
|
|
298
|
+
...options.cursor ? { cursor: options.cursor } : {},
|
|
299
|
+
...options.limit ? { limit: Number(options.limit) } : {}
|
|
300
|
+
})
|
|
301
|
+
);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
funds.command("get").argument("<fundId>").action(async (fundId) => {
|
|
305
|
+
await withClient(async (_, client) => {
|
|
306
|
+
print(await client.funds.get(fundId));
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
funds.command("positions").argument("<fundId>").action(async (fundId) => {
|
|
310
|
+
await withClient(async (_, client) => {
|
|
311
|
+
print(await client.funds.positions(fundId));
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
funds.command("prediction-positions").argument("<fundId>").action(async (fundId) => {
|
|
315
|
+
await withClient(async (_, client) => {
|
|
316
|
+
print(await client.funds.predictionPositions(fundId));
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
funds.command("orders").argument("<fundId>").action(async (fundId) => {
|
|
320
|
+
await withClient(async (_, client) => {
|
|
321
|
+
print(await client.funds.predictionOrders(fundId));
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
funds.command("trades").argument("<fundId>").option("--limit <limit>").option("--offset <offset>").action(async (fundId, options) => {
|
|
325
|
+
await withClient(async (_, client) => {
|
|
326
|
+
print(await client.funds.trades(fundId, {
|
|
327
|
+
...options.limit ? { limit: Number(options.limit) } : {},
|
|
328
|
+
...options.offset ? { offset: Number(options.offset) } : {}
|
|
329
|
+
}));
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
funds.command("cancel-order").argument("<fundId>").argument("<orderId>").action(async (fundId, orderId) => {
|
|
333
|
+
await withClient(async (_, client) => {
|
|
334
|
+
print(await client.funds.cancelPredictionOrder(fundId, orderId));
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
funds.command("buy").argument("<fundId>").argument("<marketId>").requiredOption("--outcome-id <outcomeId>").requiredOption("--shares <shares>").requiredOption("--price <price>").action(async (fundId, marketId, options) => {
|
|
338
|
+
await withClient(async (_, client) => {
|
|
339
|
+
print(await client.funds.placePredictionOrder(fundId, {
|
|
340
|
+
marketId,
|
|
341
|
+
outcomeId: options.outcomeId,
|
|
342
|
+
side: "BUY",
|
|
343
|
+
type: "LIMIT",
|
|
344
|
+
price: Number(options.price),
|
|
345
|
+
quantity: Number(options.shares)
|
|
346
|
+
}));
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
funds.command("sell").argument("<fundId>").argument("<marketId>").requiredOption("--outcome-id <outcomeId>").requiredOption("--shares <shares>").requiredOption("--price <price>").action(async (fundId, marketId, options) => {
|
|
350
|
+
await withClient(async (_, client) => {
|
|
351
|
+
print(await client.funds.placePredictionOrder(fundId, {
|
|
352
|
+
marketId,
|
|
353
|
+
outcomeId: options.outcomeId,
|
|
354
|
+
side: "SELL",
|
|
355
|
+
type: "LIMIT",
|
|
356
|
+
price: Number(options.price),
|
|
357
|
+
quantity: Number(options.shares)
|
|
358
|
+
}));
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
funds.command("crypto-buy").argument("<fundId>").argument("<symbol>").requiredOption("--quantity <quantity>").action(async (fundId, symbol, options) => {
|
|
362
|
+
await withClient(async (_, client) => {
|
|
363
|
+
print(await client.funds.tradeCrypto(fundId, { symbol, side: "BUY", quantity: Number(options.quantity) }));
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
funds.command("crypto-sell").argument("<fundId>").argument("<symbol>").requiredOption("--quantity <quantity>").action(async (fundId, symbol, options) => {
|
|
367
|
+
await withClient(async (_, client) => {
|
|
368
|
+
print(await client.funds.tradeCrypto(fundId, { symbol, side: "SELL", quantity: Number(options.quantity) }));
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
program.command("search").argument("<query>").option("--limit <limit>").option("--offset <offset>").action(async (query, options) => {
|
|
372
|
+
await withClient(async (_, client) => {
|
|
373
|
+
print(await client.search.query(query, {
|
|
374
|
+
...options.limit ? { limit: Number(options.limit) } : {},
|
|
375
|
+
...options.offset ? { offset: Number(options.offset) } : {}
|
|
376
|
+
}));
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
program.command("leaderboard").option("--category <category>").option("--sort <sort>").action(async (options) => {
|
|
380
|
+
await withClient(async (_, client) => {
|
|
381
|
+
const params = {};
|
|
382
|
+
if (options.category) {
|
|
383
|
+
params.category = options.category;
|
|
384
|
+
}
|
|
385
|
+
if (options.sort) {
|
|
386
|
+
params.sort = options.sort;
|
|
387
|
+
}
|
|
388
|
+
print(await client.leaderboards.get(params));
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
program.command("profile").argument("<username>").action(async (username) => {
|
|
392
|
+
await withClient(async (_, client) => {
|
|
393
|
+
print(await client.profiles.get(username));
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
program.command("follow").argument("<userId>").action(async (userId) => {
|
|
397
|
+
await withClient(async (_, client) => {
|
|
398
|
+
print(await client.social.follow(userId));
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
program.command("unfollow").argument("<userId>").action(async (userId) => {
|
|
402
|
+
await withClient(async (_, client) => {
|
|
403
|
+
print(await client.social.unfollow(userId));
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
program.command("followers").action(async () => {
|
|
407
|
+
await withClient(async (_, client) => {
|
|
408
|
+
print(await client.social.followers());
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
program.command("following").action(async () => {
|
|
412
|
+
await withClient(async (_, client) => {
|
|
413
|
+
print(await client.social.following());
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
const watchlist = program.command("watchlist").description("Watchlist");
|
|
417
|
+
watchlist.command("list").action(async () => {
|
|
418
|
+
await withClient(async (_, client) => {
|
|
419
|
+
print(await client.watchlist.list());
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
watchlist.command("add").argument("<symbol>").action(async (symbol) => {
|
|
423
|
+
await withClient(async (_, client) => {
|
|
424
|
+
print(await client.watchlist.add(symbol));
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
watchlist.command("remove").argument("<symbol>").action(async (symbol) => {
|
|
428
|
+
await withClient(async (_, client) => {
|
|
429
|
+
print(await client.watchlist.remove(symbol));
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
program.command("subscription").action(async () => {
|
|
433
|
+
await withClient(async (_, client) => {
|
|
434
|
+
print(await client.billing.getSubscription());
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
program.command("upgrade").argument("<tier>").action(async (tier) => {
|
|
438
|
+
await withClient(async (_, client) => {
|
|
439
|
+
print(await client.billing.createCheckout(tier));
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
program.command("billing").action(async () => {
|
|
443
|
+
await withClient(async (_, client) => {
|
|
444
|
+
print(await client.billing.createPortalSession());
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
const intelligence = program.command("intelligence").description("Market intelligence");
|
|
448
|
+
intelligence.command("summary").action(async () => {
|
|
449
|
+
await withClient(async (_, client) => {
|
|
450
|
+
print(await client.intelligence.getSummary());
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
intelligence.command("signals").argument("<marketId>").action(async (marketId) => {
|
|
454
|
+
await withClient(async (_, client) => {
|
|
455
|
+
print(await client.intelligence.getSignals(marketId));
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
const performance = program.command("performance").description("Performance & reflection");
|
|
459
|
+
performance.command("summary").option("--period <period>", "Time period: 7d, 30d, 90d, all").option("--category <category>", "Filter by market category").action(async (options) => {
|
|
460
|
+
await withClient(async (_, client) => {
|
|
461
|
+
print(
|
|
462
|
+
await client.performance.get({
|
|
463
|
+
...options.period ? { period: options.period } : {},
|
|
464
|
+
...options.category ? { category: options.category } : {}
|
|
465
|
+
})
|
|
466
|
+
);
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
performance.command("resolved").option("--cursor <cursor>", "Pagination cursor").option("--limit <limit>", "Page size (max 50)").option("--outcome <outcome>", "Filter: correct, incorrect, all").action(async (options) => {
|
|
470
|
+
await withClient(async (_, client) => {
|
|
471
|
+
print(
|
|
472
|
+
await client.performance.getResolved({
|
|
473
|
+
...options.cursor ? { cursor: options.cursor } : {},
|
|
474
|
+
...options.limit ? { limit: Number(options.limit) } : {},
|
|
475
|
+
...options.outcome ? { outcome: options.outcome } : {}
|
|
476
|
+
})
|
|
477
|
+
);
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
performance.command("benchmarks").option("--period <period>", "Time period: 7d, 30d, 90d, all").action(async (options) => {
|
|
481
|
+
await withClient(async (_, client) => {
|
|
482
|
+
print(
|
|
483
|
+
await client.performance.getBenchmarks({
|
|
484
|
+
...options.period ? { period: options.period } : {}
|
|
485
|
+
})
|
|
486
|
+
);
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
const wars = program.command("wars").description("Trading Wars");
|
|
490
|
+
wars.command("list").action(async () => {
|
|
491
|
+
await withClient(async (_, client) => {
|
|
492
|
+
print(await client.wars.list());
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
wars.command("active").action(async () => {
|
|
496
|
+
await withClient(async (_, client) => {
|
|
497
|
+
print(await client.wars.active());
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
wars.command("get").argument("<warId>").action(async (warId) => {
|
|
501
|
+
await withClient(async (_, client) => {
|
|
502
|
+
print(await client.wars.get(warId));
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
wars.command("queue").requiredOption("--tier <tier>", "Duration tier: BLITZ, STANDARD, MARATHON").action(async (options) => {
|
|
506
|
+
await withClient(async (_, client) => {
|
|
507
|
+
print(await client.wars.enterQueue({ durationTier: options.tier }));
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
wars.command("cancel-queue").action(async () => {
|
|
511
|
+
await withClient(async (_, client) => {
|
|
512
|
+
print(await client.wars.cancelQueue());
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
wars.command("queue-status").action(async () => {
|
|
516
|
+
await withClient(async (_, client) => {
|
|
517
|
+
print(await client.wars.getQueueStatus());
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
wars.command("results").argument("<warId>").action(async (warId) => {
|
|
521
|
+
await withClient(async (_, client) => {
|
|
522
|
+
print(await client.wars.results(warId));
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
wars.command("history").action(async () => {
|
|
526
|
+
await withClient(async (_, client) => {
|
|
527
|
+
print(await client.wars.history());
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
wars.command("leaderboard").action(async () => {
|
|
531
|
+
await withClient(async (_, client) => {
|
|
532
|
+
print(await client.wars.leaderboard());
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
return program;
|
|
536
|
+
}
|
|
537
|
+
async function saveAuth(auth, email) {
|
|
538
|
+
await saveCredentials({ token: auth.token, email });
|
|
539
|
+
process.stderr.write(
|
|
540
|
+
`${import_chalk.default.green("Saved credentials")} at ${import_chalk.default.cyan(getCredentialsPath())}
|
|
541
|
+
`
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
async function placePredictionOrder(marketId, side, options) {
|
|
545
|
+
await withClient(async (_, client) => {
|
|
546
|
+
const response = await client.predictions.placeOrder(marketId, {
|
|
547
|
+
outcomeId: options.outcomeId,
|
|
548
|
+
side,
|
|
549
|
+
type: "LIMIT",
|
|
550
|
+
price: Number(options.price),
|
|
551
|
+
quantity: Number(options.shares)
|
|
552
|
+
});
|
|
553
|
+
print(response);
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
async function tradeCrypto(symbol, side, quantityRaw) {
|
|
557
|
+
await withClient(async (_, client) => {
|
|
558
|
+
const result = await client.portfolio.trade({
|
|
559
|
+
symbol,
|
|
560
|
+
side,
|
|
561
|
+
quantity: Number(quantityRaw)
|
|
562
|
+
});
|
|
563
|
+
print(result);
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// src/index.ts
|
|
568
|
+
async function main() {
|
|
569
|
+
const program = createProgram();
|
|
570
|
+
await program.parseAsync(process.argv);
|
|
571
|
+
}
|
|
572
|
+
main().catch((error) => {
|
|
573
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
574
|
+
process.stderr.write(`${message}
|
|
575
|
+
`);
|
|
576
|
+
process.exit(1);
|
|
577
|
+
});
|
|
578
|
+
//# sourceMappingURL=index.cjs.map
|