[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-81597":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":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":44,"readmeContent":45,"aiSummary":46,"trendingCount":15,"starSnapshotCount":15,"syncStatus":47,"lastSyncTime":48,"discoverSource":49},81597,"1rok","achaljhawar\u002F1rok","achaljhawar","Multi-LLM trading harness.","https:\u002F\u002Finvestingbench.vercel.app",null,"TypeScript",31,7,23,0,1,8,3,2.71,"MIT License",false,"main",true,[25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"ai","ai-agents","algorithmic-trading","alpaca","autonomous-agents","finance","gemini","investment","llm","multi-agent","openai","paper-trading","portfolio-management","portfolio-managment","stock-market","tool-calling","trading-bot","typescript","yahoo-finance","2026-06-12 02:04:17","# 1rok\n\n![1rok leaderboard](.\u002F.github\u002Fassets\u002Fleaderboard.png)\n\n`1rok` is a standalone harness for running portfolio-construction agents across OpenAI, Anthropic, Gemini, xAI, DeepSeek, GLM, and OpenRouter against the same financial tool surface. Agents query Alpaca, Yahoo Finance, FRED, and Tavily through an inline, in-process tool registry defined in this repo.\n\nLive leaderboard tracking how each model's portfolio performs in paper trading on Alpaca (started 2026-01-20): **[investingbench.vercel.app](https:\u002F\u002Finvestingbench.vercel.app\u002F)**.\n\n> [!NOTE]\n> `run` produces an artifact. `execute` places orders. They are always separate commands. `run` never touches a broker; `execute --live` is the only path to real order placement.\n\n## Features\n\n- **Inline tool registry** — `listTools` \u002F `callTool` over local handlers; one registry per pipeline run.\n- **Eight tool groups** — market, stock, research, technicals, options, earnings, portfolio, Tavily web search.\n- **Seven LLM providers** — OpenAI (GPT-5.2\u002F5.4\u002F5.5), Anthropic (Claude Opus 4.7 \u002F Sonnet 4.6 \u002F Haiku 4.5), Gemini, xAI, DeepSeek, GLM, OpenRouter — behind a single tool-calling loop.\n- **Specialist agents** — orchestrator, screener, fundamental, valuation, technical, sentiment, catalyst, macro, risk, constructor.\n- **Two-stage pipeline** — `run` emits a portfolio-construction JSON artifact; `execute` reads it and places orders via Alpaca (paper by default).\n- **Provider-agnostic schemas** — Zod definitions converted to each provider's tool-call format with shared retry\u002Floop logic.\n\n## Agent Pipeline\n\nFour stages, ten agents, one weekly run. Macro reads regime; Screener surfaces 25–30 candidates; six analysts score in parallel; Orchestrator composites; Constructor sizes trades; Alpaca executes (paper by default).\n\n```mermaid\nflowchart TD\n    Macro[\"Macro Agent\u003Cbr\u002F>\u003Ci>The Economist\u003C\u002Fi>\"]:::entry\n    Screener[\"Screener Agent\u003Cbr\u002F>\u003Ci>The Scout\u003C\u002Fi>\"]:::entry\n\n    Sentiment[\"Sentiment\u003Cbr\u002F>\u003Ci>Mood Reader\u003C\u002Fi>\"]:::analysis\n    Fundamental[\"Fundamental\u003Cbr\u002F>\u003Ci>Accountant\u003C\u002Fi>\"]:::analysis\n    Valuation[\"Valuation\u003Cbr\u002F>\u003Ci>Appraiser\u003C\u002Fi>\"]:::analysis\n    Catalyst[\"Catalyst\u003Cbr\u002F>\u003Ci>Event Watcher\u003C\u002Fi>\"]:::analysis\n    Risk[\"Risk\u003Cbr\u002F>\u003Ci>Risk Manager\u003C\u002Fi>\"]:::analysis\n    Technical[\"Technical\u003Cbr\u002F>\u003Ci>Chart Reader\u003C\u002Fi>\"]:::analysis\n\n    Orchestrator[\"Orchestrator Agent\u003Cbr\u002F>\u003Ci>The CIO\u003C\u002Fi>\"]:::synthesis\n    Constructor[\"Portfolio Constructor\u003Cbr\u002F>\u003Ci>The Trader\u003C\u002Fi>\"]:::execution\n    Execute[\"Order Execution\u003Cbr\u002F>\u003Ci>Alpaca API\u003C\u002Fi>\"]:::execution\n\n    Macro --> Screener\n    Screener --> Sentiment\n    Screener --> Fundamental\n    Screener --> Valuation\n    Screener --> Catalyst\n    Screener --> Risk\n    Screener --> Technical\n\n    Sentiment --> Orchestrator\n    Fundamental --> Orchestrator\n    Valuation --> Orchestrator\n    Catalyst --> Orchestrator\n    Risk --> Orchestrator\n    Technical --> Orchestrator\n\n    Orchestrator --> Constructor\n    Constructor --> Execute\n\n    classDef entry stroke:#ff8c00,stroke-width:2px\n    classDef analysis stroke:#888,stroke-width:1px\n    classDef synthesis stroke:#22c55e,stroke-width:2px\n    classDef execution stroke:#aaa,stroke-width:1px\n```\n\nComposite scoring weights: fundamental 20%, valuation 20%, risk 15% (inverted), technical 15%, catalyst 15%, sentiment 10%, macro gate 5%. Constructor caps at 8 positions, ≥85% invested, ≤40% per name.\n\n## Architecture\n\n```\nCLI (run | execute)\n   │\n   ▼\nProvider ── TradingPipeline ── InlineToolRegistry (per run)\n                │                       │\n                ▼                       ▼\n        Specialist agents ───── Tool handlers\n                                        │\n                                        ▼\n                              src\u002Fdata\u002Fservices\n                                        │\n                                        ▼\n                Alpaca · Yahoo Finance · FRED · Tavily\n```\n\n1. Runner builds provider + `TradingPipeline` from model id.\n2. Pipeline instantiates one `InlineToolRegistry` per run.\n3. Agents execute through provider's tool-calling loop.\n4. Tool handlers call typed services in `src\u002Fdata`.\n5. Services hit external APIs.\n\n## Layout\n\n| Path | Role |\n|---|---|\n| `src\u002Fdata` | Provider clients, domain services, types |\n| `src\u002Ftools` | Inline tool definitions + registry (`listTools` \u002F `callTool`) |\n| `src\u002Fharness\u002Fagents` | Specialist agents (orchestrator, constructor, …) |\n| `src\u002Fharness\u002Fproviders` | Provider adapters + tool-loop |\n| `src\u002Fharness\u002Fpipeline` | Run orchestration |\n| `src\u002Fcli\u002F1rok.ts` | CLI entrypoint (`run`, `execute`, `help`) |\n\n## Requirements\n\n- [Bun](https:\u002F\u002Fbun.sh) `>= 1.1.0` — supported on macOS (x64\u002Farm64), Linux (x64\u002Farm64, glibc or musl), and Windows (x64\u002Farm64).\n- API keys for the providers you intend to exercise (see [Environment](#environment))\n\n## Quick Start\n\nmacOS \u002F Linux (bash\u002Fzsh):\n\n```bash\nbun install\ncp .env.example .env   # fill in keys you actually need\nbun run typecheck\n```\n\nWindows (PowerShell):\n\n```powershell\nbun install\nCopy-Item .env.example .env   # fill in keys you actually need\nbun run typecheck\n```\n\nWindows (cmd.exe):\n\n```cmd\nbun install\ncopy .env.example .env\nbun run typecheck\n```\n\nRun a portfolio-construction pipeline:\n\n```bash\nbun run 1rok -- run --model gpt-5.2-medium\n```\n\nExecute the resulting orders file (paper by default). Path separators differ per OS:\n\n```bash\n# macOS \u002F Linux\nbun run 1rok -- execute .\u002Fresults\u002Fopenai\u002Fgpt-5.2-medium\u002Fportfolio-construction-2026-04-16T07-00-00.json\n```\n\n```powershell\n# Windows PowerShell\nbun run 1rok -- execute .\\results\\openai\\gpt-5.2-medium\\portfolio-construction-2026-04-16T07-00-00.json\n```\n\n> [!WARNING]\n> `--live` places real orders. Without it, execution targets `paper-api.alpaca.markets`.\n\n```bash\nbun run 1rok -- execute .\u002Fresults\u002F\u003C...>.json --live\nbun run 1rok -- execute .\u002Fresults\u002F\u003C...>.json --live --force\n```\n\nInstall the CLI globally on your shell:\n\n```bash\nbun link\n1rok run --model gpt-5.2-medium\n1rok execute .\u002Fresults\u002F\u003C...>.json\n```\n\nOn Windows, `bun link` creates a `1rok.cmd` shim on `PATH`; the commands above work unchanged from PowerShell or cmd.\n\n## Environment\n\nCopy `.env.example` to `.env`. Nothing is required unless you exercise that integration.\n\n**Data providers**\n\n| Var | Purpose |\n|---|---|\n| `ALPACA_API_KEY` \u002F `ALPACA_SECRET_KEY` | Bars, quotes, positions, news, order execution |\n| `FRED_API_KEY` | Macro indicators, interest rates |\n| `TAVILY_API_KEY` | Web search, page extract, site crawl |\n\nYahoo Finance needs no key.\n\n**LLM providers** — set at least one:\n\n`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GEMINI_API_KEY`, `XAI_API_KEY`, `DEEPSEEK_API_KEY`, `GLM_API_KEY`, `OPENROUTER_API_KEY`\n\n**Anthropic models**\n\n| Model id | Notes |\n|---|---|\n| `claude-opus-4-7` | Default Anthropic model |\n| `claude-opus-4-7-high` | Reasoning effort `high` |\n| `claude-opus-4-7-max` | Reasoning effort `max` |\n| `claude-sonnet-4-6` | |\n| `claude-haiku-4-5` | |\n\nThe Anthropic adapter runs through `@anthropic-ai\u002Fclaude-agent-sdk`, which ships a native `claude` binary as an optional dependency. The provider resolves that binary automatically for macOS (`darwin-arm64`, `darwin-x64`), Linux (`linux-x64`\u002F`arm64`, glibc + musl), and Windows (`win32-x64`, `win32-arm64`). Override the resolved path with `CLAUDE_CODE_EXECUTABLE` if needed (e.g. pointing at an existing `claude` install, or `claude.exe` on Windows).\n\n**Optional**\n\n- `IROK_MODEL` — default model id when `--model` is omitted.\n- `ALPACA_API_KEY_\u003CPROVIDER>` \u002F `ALPACA_SECRET_KEY_\u003CPROVIDER>` — per-model paper credentials for `execute`. Falls back to the global `ALPACA_*` keys.\n- `CLAUDE_CODE_EXECUTABLE` — absolute path to the `claude` binary the Anthropic provider should use. Only needed if auto-resolution from the SDK's optional deps fails.\n\n## Scripts\n\n```bash\nbun run typecheck   # tsc --noEmit\nbun run build       # tsc\nbun run test        # bun test\nbun run 1rok -- ... # CLI passthrough\n```\n\n## Tool Groups\n\n`market`, `stock`, `research`, `technicals`, `options`, `earnings`, `portfolio`, `tavily`. Each group registers Zod-typed definitions in `src\u002Ftools\u002Fdefinitions\u002F*` and is aggregated through `ALL_TOOLS` in `src\u002Ftools\u002Fdefinitions\u002Findex.ts`.\n\n## Programmatic Use\n\n```ts\nimport { createProviderFromModel } from \"1rok\u002Fharness\";\nimport { TradingPipeline } from \"1rok\u002Fpipeline\";\n\nconst provider = createProviderFromModel(\"gpt-5.2-medium\");\nconst pipeline = new TradingPipeline({ provider });\nconst result = await pipeline.run();\n```\n\nSubpath exports: `1rok\u002Ftools`, `1rok\u002Fdata`, `1rok\u002Fharness`, `1rok\u002Fproviders`, `1rok\u002Fagents`, `1rok\u002Fpipeline`.\n","1rok 是一个多语言模型交易框架，用于在相同的金融工具表面上运行投资组合构建代理。项目支持包括OpenAI、Anthropic、Gemini等在内的七种大型语言模型，并通过内联工具注册表与Alpaca、Yahoo Finance等数据源交互。其核心功能包括两阶段流水线处理（`run`生成投资组合配置文件而`execute`执行订单）、八个工具组以及专业化的代理角色如宏观分析员、筛选器和风险管理者等。特别适合需要比较不同AI模型在模拟或实盘交易中表现的研究者及开发者使用。此外，项目采用TypeScript编写，确保了良好的类型安全性和开发效率。",2,"2026-06-11 04:05:39","CREATED_QUERY"]