[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-79872":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":10,"pushedAt":10,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":15,"starSnapshotCount":15,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},79872,"OpenWhale","OpenWhale-Org\u002FOpenWhale","OpenWhale-Org","The programmable layer for composable, AI-native economic strategies","https:\u002F\u002Fow.gm.town",null,"TypeScript",133,7,4,0,1,2.71,false,"main",true,[22,23,24,25],"ai-agent","crypto","strategy","trading","2026-06-12 02:03:55","# OpenWhale\n\n\u003Cimg src=\".\u002Flogo.svg\" width=\"64\" height=\"64\" \u002F>\n\n**The programmable layer for composable, AI-native economic strategies**\n\n![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-blue)\n![TypeScript](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flanguage-TypeScript-3178c6)\n![Node](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fnode-%3E%3D20-brightgreen)\n\nOpenWhale is a TypeScript framework for building automated economic strategies. Monitor, Strategy, and Executor are fully decoupled — the same strategy code runs on any exchange, plugs into any data source, and can be generated or evolved by an AI at runtime.\n\n---\n\n## Why OpenWhale\n\n- **Fully decoupled layers** — Monitor, Strategy, and Executor are independent. Replace any layer without touching the others.\n- **Exchange-agnostic strategies** — Strategy code has zero knowledge of which exchange it runs on. One strategy, any platform.\n- **AI as a programmer** — LLM inference is built into the strategy layer. AI generates type-safe TypeScript strategies that are compiled, hot-loaded, and can evolve automatically — no token cost per tick.\n- **Structured trigger system** — Combine Cron schedules with multi-source Monitor conditions (AND logic, time window). Express \"fire only when A and B both happen within 60 seconds\" without polling.\n- **Type-safe plugin architecture** — Every Monitor, Executor, and Strategy implements a strict TypeScript interface. IDE support, safe refactoring, and AI-generated code that the type system validates at compile time.\n\n---\n\n## Code Examples\n\n### A minimal strategy\n\n```typescript\nclass MomentumStrategy extends BaseStrategy {\n  readonly strategyId = 'momentum'\n\n  async evaluate(context: StrategyContext) {\n    const { symbol, threshold } = this.params.base\n    const tick = context.getData('price', symbol)\n    if (!tick || tick.price \u003C threshold) return []\n\n    return [\n        this.instruction('perp', 'placeOrder', {\n          symbol, side: 'buy', type: 'market', amount: 0.01,\n        })\n    ]\n  }\n}\n```\n\n### Assembling the runtime\n\n```typescript\nconst runtime = new OpenWhaleRuntime({ database, credentialStore })\nruntime.loadPlugin(hyperliquidPlugin)\nawait runtime.start()\nawait runtime.activate({\n  strategyId: 'hyperliquid\u002Fcopy-trading',\n  params: { base: { targetAddress: '0x...', ratio: 0.5 } },\n})\n```\n\n### AI-driven strategy with structured output\n\n```typescript\nasync evaluate(context: StrategyContext) {\n  const data = context.getData('price', 'BTC\u002FUSDC:USDC')\n\n  const { action, confidence } = await this.llm({\n    messages: [{ role: 'user', content: JSON.stringify(data) }],\n    schema: z.object({\n      action: z.enum(['buy', 'sell', 'hold']),\n      confidence: z.number(),\n    }),\n  })\n\n  if (action === 'hold' || confidence \u003C 0.7) return []\n\n  return [\n      this.instruction('perp', 'placeOrder', {\n        symbol: 'BTC\u002FUSDC:USDC', side: action, type: 'market', amount: 0.01,\n      })\n  ]\n}\n```\n\n---\n\n## Features\n\n- **Plugin architecture** — exchanges, account types, monitors, and executors register through standard interfaces; the framework manages lifecycle and dependency injection\n- **Composable by design** — Monitor \u002F Strategy \u002F Executor mix and match freely; swap `MockExecutor` for simulation with one line\n- **Exchange-agnostic strategies** — strategies access accounts through `IAccount` and express intent through `ExecutionInstruction`, never calling exchange SDKs directly\n- **Built-in LLM inference** — call LLMs with structured output (Zod schema) directly inside strategy `evaluate()`; supports OpenAI, Anthropic, Google, Groq, xAI, and custom providers\n- **Structured trigger system** — Cron + Monitor condition AND combinations with time windows; `TriggerManager` handles all scheduling and state\n- **Auto-derived param UI** — attach `.meta()` to Zod schema fields; Dashboard renders typed form controls automatically, no per-strategy UI code needed\n- **Hot-reload compiled strategies** — AI-generated TypeScript strategies are compiled with esbuild and loaded at runtime without restart\n- **Persistent storage** — Monitor data auto-persisted as JSONL; built-in KV store per strategy instance; SQLite adapter included\n\n---\n\n## Use Cases\n\n| Scenario | Description |\n|----------|-------------|\n| **Copy Trading** | Monitor a target wallet, mirror its trades proportionally with position caps |\n| **Cross-exchange Arbitrage** | Trigger only when price spread AND funding rate conditions are met simultaneously |\n| **AI Market Making** | LLM analyzes order book depth and volatility, dynamically adjusts bid\u002Fask quotes |\n| **On-chain Event Response** | Listen to smart contract events, trigger on-chain or off-chain actions automatically |\n| **Multi-condition Signal Strategy** | Combine price, volume, and funding rate monitors — fire only when all conditions align within a time window |\n| **NFT \u002F Token Launch Sniping** | Monitor mempool or launchpad events, execute within milliseconds of a trigger |\n| **Yield Optimization** | Monitor APY across protocols, rebalance positions when spread exceeds threshold |\n\n---\n\n## Architecture\n\n```\nMonitor (data collection)\n    ↓ emit(key, data)\nTriggerManager (trigger evaluation)\n    ↓ StrategyContext\nStrategy (rules \u002F AI inference)\n    ↓ ExecutionInstruction[]\nExecutionQueue\n    ↓\nExecutor (trade execution)\n```\n\nEach layer is a pure interface. Monitors emit keyed data events. TriggerManager evaluates Cron + Monitor conditions and fires a `StrategyContext`. Strategies return `ExecutionInstruction[]` — they never call exchange APIs directly. Executors consume the queue and handle the actual API calls.\n\n---\n\n## Quick Start\n\n### Prerequisites\n\n- Node.js ≥ 20, pnpm ≥ 8\n- A Hyperliquid account with a wallet address and private key\n\n### Install\n\n```bash\npnpm install\npnpm build\n```\n\n### Run the copy trading example\n\n```bash\ncd packages\u002Fhyperliquid\ncp examples\u002F.env.example examples\u002F.env\n```\n\nEdit `examples\u002F.env`:\n\n```env\nHL_WALLET_ADDRESS=0x...        # your wallet address\nHL_PRIVATE_KEY=0x...           # your private key\nHL_TARGET_ADDRESS=0x...        # address to copy trades from\nMASTER_KEY=your-32-byte-hex    # encryption key for credential store\n```\n\n```bash\npnpm example:copy-trading\n```\n\n### Dashboard\n\n```bash\ncd packages\u002Fdashboard\ncp .env.example .env.local     # fill in OPENWHALE_MASTER_KEY\npnpm dev\n```\n\nOpen `http:\u002F\u002Flocalhost:3000` to manage strategy instances, view monitor data, and configure credentials.\n\n---\n\n## Packages\n\n| Package | Description |\n|---------|-------------|\n| [`@openwhale\u002Fcore`](.\u002Fpackages\u002Fcore) | Strategy engine core: Monitor, Trigger, Strategy, Executor, Runtime, Account, CompiledLoader |\n| [`@openwhale\u002Fhyperliquid`](.\u002Fpackages\u002Fhyperliquid) | Hyperliquid plugin: HyperliquidAdapter (ccxt.pro), HyperliquidAccount, UserTradesMonitor, PerpTradingExecutor, CopyTradingStrategy |\n| [`@openwhale\u002Fdashboard`](.\u002Fpackages\u002Fdashboard) | Next.js management dashboard: strategy instance management, registry browser, credential management, auto-rendered param forms |\n| `@openwhale\u002Fassistant` | Personal assistant layer: session management, LLM conversation, tool calls *(planned)* |\n| `@openwhale\u002Fmcp-server` | Expose the strategy engine as an MCP server *(planned)* |\n\n---\n\n## Roadmap\n\n### M1 — Compiler\n\nA conversational compiler that guides users step by step to define strategy logic, then compiles Monitor \u002F Strategy \u002F Executor components into type-safe TypeScript. Runs static analysis, unit tests, and mock simulation automatically. Hot-loads the result into the runtime — ready to run out of the box.\n\n### M2 — Optimizer\n\nDual-agent optimization loop: an analysis agent reads runtime performance and historical monitor data to generate an optimization plan; an execution agent adjusts parameters or rewrites strategy code and validates the result through backtesting. Triggered automatically on a schedule, manually from the Dashboard, or conversationally through the Assistant.\n\n### M3 — Assistant\n\nA unified conversational interface for the full strategy lifecycle: create and manage instances, trigger the Compiler to build new strategies, trigger the Optimizer to tune existing ones, receive proactive alerts and performance reports. Includes basic information retrieval — market data, on-chain activity, news feeds, signal sources.\n\n### M4 — MCP Server\n\nExpose the core engine capabilities as standard MCP tools, enabling external AI agents to drive strategy creation, activation, and optimization directly.\n\n---\n\n## Contributing\n\nOpenWhale is in active early development. The core engine is working, and we're building the rest in the open. If you're a developer interested in composable strategy infrastructure, AI-native trading systems, or just want to run your own automated strategies — we'd love your contributions.\n\n- Open an issue to discuss ideas or report bugs\n- Submit a PR for fixes, new exchange plugins, or strategy examples\n- Star the repo if you find it useful — it helps others discover the project\n\n---\n\n## License\n\nMIT\n","OpenWhale 是一个用于构建可组合、AI 原生经济策略的 TypeScript 框架。该项目的核心功能包括完全解耦的监控、策略和执行层，使得同一策略代码可以在任何交易所运行，并且可以接入任何数据源。此外，它还支持通过 AI 生成或演化策略，无需每笔交易都消耗令牌。OpenWhale 适合需要高度灵活性和自动化程度高的金融场景，如加密货币交易策略开发，尤其适用于那些希望利用人工智能技术来优化其投资决策过程的用户。",2,"2026-06-11 03:58:22","CREATED_QUERY"]