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