@rekt-trading/wheelman 0.0.0-stage → 1.0.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.
@@ -0,0 +1,34 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ // The strategy contract and the registry. A strategy reads prices and its own positions and returns
10
+ // intents. It sends nothing: the risk guard checks every intent, then the venue sends it.
11
+ import { knockoutFade, knockoutMomentum, knockoutStraddle } from "./knockout.js";
12
+ import { minuteSchedule, minuteTrend } from "./minute.js";
13
+ import { template } from "./template.js";
14
+ /** The signed move from `from` to `to`, in basis points. */
15
+ export const moveBps = (from, to) => ((to - from) / from) * 10_000;
16
+ /**
17
+ * The registry: the built-in strategies, plus every strategy exported as `strategies` by the
18
+ * modules listed in EXTRA_STRATEGIES. Add your own there without editing this file.
19
+ */
20
+ export async function registry(extraModules = []) {
21
+ const builtIn = [knockoutMomentum, knockoutFade, knockoutStraddle, minuteTrend, minuteSchedule, template];
22
+ const all = new Map(builtIn.map((s) => [s.id, s]));
23
+ for (const path of extraModules) {
24
+ const mod = (await import(__rewriteRelativeImportExtension(new URL(path, `file://${process.cwd()}/`).href)));
25
+ if (!Array.isArray(mod.strategies))
26
+ throw new Error(`${path} exports no "strategies" array`);
27
+ for (const s of mod.strategies) {
28
+ if (all.has(s.id))
29
+ throw new Error(`two strategies are named ${s.id}`);
30
+ all.set(s.id, s);
31
+ }
32
+ }
33
+ return all;
34
+ }
@@ -0,0 +1,111 @@
1
+ // Knockout strategies. A position ends at its barrier (the stake is gone), at its take-profit, at its
2
+ // own timer, or when the bot asks to close it. The venue's keepers complete every close.
3
+ import { moveBps } from "./index.js";
4
+ const stake = { kind: 'usdc', default: '1', min: '0.2', max: '1000', help: 'stake per position, in USDC' };
5
+ const takeProfit = (d) => ({
6
+ kind: 'number', default: d, min: 2, max: 1000, zeroOff: true,
7
+ help: 'take-profit as a multiple of the stake (2 or more), 0 for none',
8
+ });
9
+ const timeStop = (d) => ({
10
+ kind: 'number', default: d, min: 26, max: 86_400, zeroOff: true,
11
+ help: 'the position timer in seconds (26 or more): the venue closes the position then; 0 for none',
12
+ });
13
+ const cooldown = (d) => ({ kind: 'number', default: d, min: 0, max: 86_400, help: 'seconds to wait after a position ends' });
14
+ /** True while the strategy has a position, or ended one less than `cooldown_s` ago. */
15
+ function busy(ctx) {
16
+ if (ctx.positions.length > 0) {
17
+ ctx.memory.lastBusy = ctx.now;
18
+ return true;
19
+ }
20
+ const last = ctx.memory.lastBusy;
21
+ return last !== undefined && ctx.now - last < ctx.params.cooldown_s * 1000;
22
+ }
23
+ function open(ctx, side, group) {
24
+ return {
25
+ kind: 'open',
26
+ side,
27
+ stake: ctx.params.stake_usdc,
28
+ takeProfitX: ctx.params.take_profit_x,
29
+ timerS: ctx.params.time_stop_s,
30
+ ...(group === undefined ? {} : { group }),
31
+ };
32
+ }
33
+ export const knockoutMomentum = {
34
+ id: 'knockout-momentum',
35
+ game: 'knockout',
36
+ description: 'Open in the direction of a move larger than trigger_bps over lookback_s.',
37
+ params: {
38
+ stake_usdc: stake,
39
+ lookback_s: { kind: 'number', default: '30', min: 5, max: 3600, help: 'the window the move is measured over, in seconds' },
40
+ trigger_bps: { kind: 'number', default: '5', min: 1, max: 1000, help: 'the smallest move that opens a position, in basis points' },
41
+ take_profit_x: takeProfit('2'),
42
+ time_stop_s: timeStop('60'),
43
+ cooldown_s: cooldown('60'),
44
+ },
45
+ onTick(ctx) {
46
+ if (busy(ctx))
47
+ return [];
48
+ const past = ctx.priceAgo(ctx.params.lookback_s);
49
+ if (past === null)
50
+ return [];
51
+ const move = moveBps(past, ctx.price);
52
+ if (Math.abs(move) < ctx.params.trigger_bps)
53
+ return [];
54
+ return [open(ctx, move > 0 ? 'long' : 'short')];
55
+ },
56
+ };
57
+ export const knockoutFade = {
58
+ id: 'knockout-fade',
59
+ game: 'knockout',
60
+ description: 'Open against a sharp move; close when the price is back where the move started.',
61
+ params: {
62
+ stake_usdc: stake,
63
+ lookback_s: { kind: 'number', default: '20', min: 5, max: 3600, help: 'the window the move is measured over, in seconds' },
64
+ trigger_bps: { kind: 'number', default: '10', min: 1, max: 1000, help: 'the smallest move that opens a position, in basis points' },
65
+ take_profit_x: takeProfit('2'),
66
+ time_stop_s: timeStop('30'),
67
+ cooldown_s: cooldown('60'),
68
+ close_on_revert: { kind: 'choice', default: 'yes', choices: ['yes', 'no'], help: 'close when the price returns to where the move started' },
69
+ },
70
+ onTick(ctx) {
71
+ const waiting = busy(ctx);
72
+ const live = ctx.positions.find((p) => p.entry !== null && !p.closing);
73
+ const from = ctx.memory.from;
74
+ if (live && from !== undefined && ctx.params.close_on_revert === 'yes') {
75
+ const back = live.side === 'long' ? ctx.price >= from : ctx.price <= from;
76
+ return back ? [{ kind: 'close', id: live.id }] : [];
77
+ }
78
+ if (waiting)
79
+ return [];
80
+ const past = ctx.priceAgo(ctx.params.lookback_s);
81
+ if (past === null)
82
+ return [];
83
+ const move = moveBps(past, ctx.price);
84
+ if (Math.abs(move) < ctx.params.trigger_bps)
85
+ return [];
86
+ ctx.memory.from = past;
87
+ return [open(ctx, move > 0 ? 'short' : 'long')];
88
+ },
89
+ };
90
+ export const knockoutStraddle = {
91
+ id: 'knockout-straddle',
92
+ game: 'knockout',
93
+ description: 'In a quiet market, open a long and a short of the same stake together.',
94
+ params: {
95
+ stake_usdc: { ...stake, help: 'stake of each side, in USDC' },
96
+ quiet_s: { kind: 'number', default: '60', min: 5, max: 3600, help: 'the window the quiet filter looks at, in seconds' },
97
+ quiet_bps: { kind: 'number', default: '3', min: 0.1, max: 1000, help: 'open only when the range over quiet_s is at most this, in basis points' },
98
+ take_profit_x: takeProfit('3'),
99
+ time_stop_s: timeStop('120'),
100
+ cooldown_s: cooldown('120'),
101
+ },
102
+ onTick(ctx) {
103
+ if (busy(ctx))
104
+ return [];
105
+ const r = ctx.range(ctx.params.quiet_s);
106
+ if (r === null || moveBps(r.low, r.high) > ctx.params.quiet_bps)
107
+ return [];
108
+ const group = `straddle-${ctx.now}`;
109
+ return [open(ctx, 'long', group), open(ctx, 'short', group)];
110
+ },
111
+ };
@@ -0,0 +1,53 @@
1
+ // Minute strategies. A round runs on Minute's own clock (sixty seconds unless Minute's config says
2
+ // otherwise) and has no early exit. The venue's keepers settle every round.
3
+ import { moveBps } from "./index.js";
4
+ const stake = { kind: 'usdc', default: '1', min: '0.01', max: '100', help: 'the total each round takes from the wallet, in USDC' };
5
+ export const minuteTrend = {
6
+ id: 'minute-trend',
7
+ game: 'minute',
8
+ description: 'Each round, take the side of the move over lookback_s; skip a move below min_bps.',
9
+ params: {
10
+ stake_usdc: stake,
11
+ lookback_s: { kind: 'number', default: '30', min: 5, max: 3600, help: 'the window the trend is measured over, in seconds' },
12
+ min_bps: { kind: 'number', default: '2', min: 0, max: 1000, help: 'skip the round when the move is smaller than this, in basis points' },
13
+ },
14
+ onTick(ctx) {
15
+ if (ctx.positions.length > 0)
16
+ return [];
17
+ const past = ctx.priceAgo(ctx.params.lookback_s);
18
+ if (past === null)
19
+ return [];
20
+ const move = moveBps(past, ctx.price);
21
+ if (move === 0 || Math.abs(move) < ctx.params.min_bps)
22
+ return [];
23
+ return [{ kind: 'round', side: move > 0 ? 'long' : 'short', stake: ctx.params.stake_usdc }];
24
+ },
25
+ };
26
+ export const minuteSchedule = {
27
+ id: 'minute-schedule',
28
+ game: 'minute',
29
+ description: 'Play every Nth minute at a fixed stake and side rule, inside a daily UTC window.',
30
+ params: {
31
+ stake_usdc: stake,
32
+ every_n: { kind: 'number', default: '1', min: 1, max: 1440, help: 'play in every Nth minute of the clock' },
33
+ side: { kind: 'choice', default: 'alternate', choices: ['long', 'short', 'alternate'], help: 'the side of each round' },
34
+ start_hour_utc: { kind: 'number', default: '0', min: 0, max: 23, help: 'the first hour of the window (UTC)' },
35
+ end_hour_utc: { kind: 'number', default: '24', min: 1, max: 24, help: 'the hour the window ends (UTC)' },
36
+ },
37
+ onTick(ctx) {
38
+ if (ctx.positions.length > 0)
39
+ return [];
40
+ const minute = Math.floor(ctx.now / 60_000);
41
+ const hour = new Date(ctx.now).getUTCHours();
42
+ const p = ctx.params;
43
+ if (hour < p.start_hour_utc || hour >= p.end_hour_utc)
44
+ return [];
45
+ if (minute % p.every_n !== 0 || ctx.memory.lastMinute === minute)
46
+ return [];
47
+ ctx.memory.lastMinute = minute;
48
+ const played = ctx.memory.played ?? 0;
49
+ ctx.memory.played = played + 1;
50
+ const side = p.side === 'alternate' ? (played % 2 === 0 ? 'long' : 'short') : p.side;
51
+ return [{ kind: 'round', side, stake: p.stake_usdc }];
52
+ },
53
+ };
@@ -0,0 +1,24 @@
1
+ export const template = {
2
+ id: 'template',
3
+ game: 'knockout',
4
+ description: 'A skeleton that never trades. Copy it to write your own strategy.',
5
+ params: {
6
+ stake_usdc: { kind: 'usdc', default: '1', min: '0.2', max: '1000', help: 'stake per position, in USDC' },
7
+ lookback_s: { kind: 'number', default: '60', min: 5, max: 3600, help: 'a window, in seconds' },
8
+ },
9
+ onTick(ctx) {
10
+ // Everything the strategy may read:
11
+ // ctx.now, ctx.price, ctx.priceAgo(seconds), ctx.range(seconds)
12
+ // ctx.positions this wallet's positions on ctx.market (id, side, stake, entry, openedMs, closing)
13
+ // ctx.params the values from PARAM_* in .env, inside the bounds above
14
+ // ctx.memory an object you may write to; it lasts as long as the process
15
+ //
16
+ // Example: open a long when the price is above where it was lookback_s ago.
17
+ // const past = ctx.priceAgo(ctx.params.lookback_s as number);
18
+ // if (ctx.positions.length === 0 && past !== null && ctx.price > past) {
19
+ // return [{ kind: 'open', side: 'long', stake: ctx.params.stake_usdc as bigint, takeProfitX: 2, timerS: 60 }];
20
+ // }
21
+ void ctx;
22
+ return [];
23
+ },
24
+ };
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@rekt-trading/wheelman",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Wheelman, the Rekt trading bot and CLI, for Knockout and Minute: a bot, a command line and an MCP server for agents.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=22.18"
9
+ },
10
+ "bin": {
11
+ "wheelman": "dist/cli.js"
12
+ },
13
+ "scripts": {
14
+ "wheelman": "node src/cli.ts",
15
+ "setup": "node src/cli.ts setup",
16
+ "start": "node src/cli.ts run",
17
+ "paper": "node src/cli.ts run --paper",
18
+ "dry-run": "node src/cli.ts run --dry-run",
19
+ "test": "node --test test/*.test.ts",
20
+ "check": "tsc --noEmit && npm test",
21
+ "build": "rm -rf dist && tsc -p tsconfig.build.json && chmod +x dist/cli.js",
22
+ "prepack": "npm run build"
23
+ },
24
+ "dependencies": {
25
+ "@rekt-trading/1000x": "^0.5.0",
26
+ "@solana/web3.js": "^1.98.4"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^24.0.0",
30
+ "typescript": "^5.9.0"
31
+ },
32
+ "homepage": "https://docs.rekt.money/tools/wheelman",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/Asymmetra/rekt-wheelman.git"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/Asymmetra/rekt-wheelman/issues"
39
+ },
40
+ "keywords": [
41
+ "rekt",
42
+ "knockout",
43
+ "minute",
44
+ "solana",
45
+ "trading-bot",
46
+ "mcp",
47
+ "cli"
48
+ ],
49
+ "files": [
50
+ "dist",
51
+ "skills",
52
+ "README.md",
53
+ "LICENSE",
54
+ ".env.example"
55
+ ],
56
+ "publishConfig": {
57
+ "access": "public"
58
+ }
59
+ }
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: wheelman
3
+ description: Trade on Rekt Knockout and Minute with the wheelman CLI - read markets, preview what an open costs and pays, open and close positions, check positions and the session key, on paper or live. Use when the user asks to trade on Rekt, Knockout or Minute, to check their Rekt positions, or to run Wheelman.
4
+ ---
5
+
6
+ # Wheelman
7
+
8
+ `wheelman` is a command line for Rekt Knockout (positions with a barrier and a take-profit) and Minute
9
+ (sixty-second rounds). Run it as `wheelman <command>` (installed with `npm install -g @rekt-trading/wheelman`), or from a
10
+ clone as `node src/cli.ts <command>`. Always add `-o json`.
11
+
12
+ ## The answer
13
+
14
+ Every command prints one JSON line:
15
+
16
+ - `{"ok": true, "data": ...}`
17
+ - `{"ok": false, "error": {"category", "code", "message", "retryable"}}`
18
+
19
+ Send the same command again only when `retryable` is `true`: then a resend cannot open a second
20
+ position. On `false`, read `message`, change something, or ask the user. Categories: `config` (fix the
21
+ arguments or the settings), `risk` (a limit the user set), `venue` (the program refused; `code` is its
22
+ error name), `rpc`, `send` (`UNCONFIRMED`: run `positions` before anything else), `session`, `paper`.
23
+
24
+ ## Rules
25
+
26
+ 1. **Paper first.** Use `--paper` until the user asks for live trading. Paper sends nothing.
27
+ 2. **Preview before an open.** `preview` gives the payout at the target and at the barrier (nothing),
28
+ after every fee. Show it to the user.
29
+ 3. **Live trading uses a session key only.** The user (the owner) runs `wheelman session start`; you
30
+ never hold or ask for the owner's key. Never print a key, a token or an RPC URL.
31
+ 4. **Never change a limit or a stake the user set** (`MAX_STAKE_USDC`, `MAX_OPEN`, `DAILY_LOSS_USDC`,
32
+ `MIN_BALANCE_USDC`, `PARAM_STAKE_USDC`). A `risk` refusal is the user's limit working.
33
+ 5. **Report facts.** Say what happened and what it paid. Never state odds, a win rate or an expected
34
+ value, and never present a paper result as what live trading pays.
35
+
36
+ ## Commands
37
+
38
+ | command | what it does |
39
+ |---|---|
40
+ | `markets` | every market: open or not and why, stake bounds, leverage, fees |
41
+ | `preview BTC long 1.00 --target 2` | what an open costs, and pays at its target and at its barrier |
42
+ | `open BTC long 1.00 --target 2 --timer 60` | open a Knockout position (`--paper`, `--dry-run`) |
43
+ | `open BTC short 0.25 --minute` | open a Minute round |
44
+ | `close 74` | ask the venue to close position 74 (`--paper`, `--dry-run`) |
45
+ | `positions` | open positions, rounds, balances, today's result (`--paper`: the paper account) |
46
+ | `session status` | the session key: active or not, what it may still spend, when it expires |
47
+
48
+ Amounts are USDC text with 6 decimals. Ids are text. A position opens as an order: the venue's next
49
+ price fills it, so `entryPrice` is `null` for a moment. A Minute round has no early close.
50
+
51
+ ## Set up
52
+
53
+ 1. The owner: `wheelman setup` (wallet, RPC, limits), then
54
+ `wheelman session start --allowance 20 --expires 24h`. It prints `OWNER` and `SESSION_KEYPAIR_PATH`.
55
+ 2. The agent's settings file holds `RPC_URL`, `OWNER`, `SESSION_KEYPAIR_PATH` and the risk limits, and
56
+ no owner key. Pass it with `--env <file>`.
57
+ 3. The same commands are MCP tools: `node src/cli.ts mcp --env <file>` (add `--paper` for paper-only
58
+ trading tools).
59
+
60
+ To install this skill, copy the `skills/wheelman` folder into your agent's skills folder: Claude Code
61
+ reads `~/.claude/skills/`, Codex reads `~/.codex/skills/`, Cursor reads `~/.cursor/skills/`.