{"id":49827446,"url":"https://github.com/linq-team/kalshi-agent","last_synced_at":"2026-05-13T18:43:20.019Z","repository":{"id":338457390,"uuid":"1157960847","full_name":"linq-team/kalshi-agent","owner":"linq-team","description":"A prediction market trading agent for Kalshi, accessible via iMessage. Built on Linq Blue and Claude.","archived":false,"fork":false,"pushed_at":"2026-03-30T17:41:42.000Z","size":2004,"stargazers_count":8,"open_issues_count":4,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-13T18:43:16.308Z","etag":null,"topics":["ai-agent","anthropic","claude","imessage","kalshi","linq","prediction-markets","trading","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linq-team.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-14T15:22:49.000Z","updated_at":"2026-05-03T13:42:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/linq-team/kalshi-agent","commit_stats":null,"previous_names":["linq-team/kalshi-agent"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/linq-team/kalshi-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linq-team%2Fkalshi-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linq-team%2Fkalshi-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linq-team%2Fkalshi-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linq-team%2Fkalshi-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linq-team","download_url":"https://codeload.github.com/linq-team/kalshi-agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linq-team%2Fkalshi-agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32995915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"ssl_error","status_checked_at":"2026-05-13T13:14:51.610Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agent","anthropic","claude","imessage","kalshi","linq","prediction-markets","trading","typescript"],"created_at":"2026-05-13T18:43:17.097Z","updated_at":"2026-05-13T18:43:20.013Z","avatar_url":"https://github.com/linq-team.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kalshi Agent\n\nA prediction market trading agent for [Kalshi](https://kalshi.com), accessible via iMessage. Built on [Linq Blue](https://linqapp.com) and powered by Claude (Anthropic).\n\n![Demo Screenshot](public/images/kalshi-demo.png)\n\n## What it does\n\n- **Trade via text** — buy, sell, and cancel orders on Kalshi through iMessage\n- **Search \u0026 analyze markets** — browse trending markets, check prices, volume, and orderbook depth\n- **Portfolio tracking** — check balance, positions, and P\u0026L with a text\n- **Multi-user onboarding** — each user connects their own Kalshi account via a magic link, no shared credentials\n\n## Architecture\n\n```\nUser ──iMessage──▶ Linq Blue ──webhook──▶ kalshi-agent ──▶ Claude (Anthropic)\n                                              │                    │\n                                              │     ◀── tools ◀────┘\n                                              │     (market search,\n                                              │      trading, web\n                                              │      search)\n                                              │                    │\n                                              ▼                    ▼\nUser ◀─iMessage── Linq Blue ◀───API──── Response          Kalshi API\n```\n\n## Quick Start\n\n### Prerequisites\n\n- [Node.js](https://nodejs.org) 20+\n- [ngrok](https://ngrok.com) (for local development)\n- [Linq Blue](https://linqapp.com) account (free sandbox)\n- [Kalshi](https://kalshi.com) account with API access\n- [Anthropic](https://console.anthropic.com) API key\n\n### Setup\n\n```bash\n# Clone the repo\ngit clone https://github.com/linq-team/kalshi-agent.git\ncd kalshi-agent\n\n# Install dependencies\nnpm install\n\n# Copy environment template\ncp .env.example .env\n```\n\nEdit `.env` and fill in your keys. At minimum you need:\n\n- `ANTHROPIC_API_KEY` — from [console.anthropic.com](https://console.anthropic.com)\n- `LINQ_API_TOKEN` — from your Linq Blue dashboard\n- `LINQ_AGENT_BOT_NUMBERS` — your Linq Blue phone number\n\nGenerate an encryption key for credential storage:\n\n```bash\nnode -e \"console.log(require('crypto').randomBytes(32).toString('hex'))\"\n```\n\nPaste the output into `CREDENTIAL_ENCRYPTION_KEY` in your `.env`.\n\n### Run\n\n```bash\n# Start the dev server\nnpm run dev\n\n# In another terminal, expose via ngrok\nngrok http 3000\n```\n\nCopy the ngrok URL and set it as your webhook URL in the [Linq Blue dashboard](https://linqapp.com). Then text your Linq Blue number — you'll get a magic link to connect your Kalshi account, and you're trading.\n\n## Environment Variables\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `ANTHROPIC_API_KEY` | Yes | Claude API key |\n| `LINQ_API_TOKEN` | Yes | Linq Blue partner token |\n| `LINQ_AGENT_BOT_NUMBERS` | Yes | Your Linq Blue phone number(s), comma-separated |\n| `BASE_URL` | Yes | Public URL for magic link generation (e.g. your ngrok URL) |\n| `CREDENTIAL_ENCRYPTION_KEY` | Yes | 64 hex chars for encrypting stored Kalshi credentials |\n| `KALSHI_API_KEY_ID` | No | Default Kalshi API key ID (for public market data before users onboard) |\n| `KALSHI_PRIVATE_KEY_PATH` | No | Path to default Kalshi private key `.pem` |\n| `PORT` | No | Server port (default: 3000) |\n| `NODE_ENV` | No | Set to `production` for HTTPS enforcement |\n| `ALLOWED_SENDERS` | No | Lock to specific phone numbers during dev, comma-separated |\n| `IGNORED_SENDERS` | No | Phone numbers to ignore, comma-separated |\n\n## How it works\n\n1. User texts the Linq Blue number via iMessage\n2. Linq Blue sends a webhook to your server\n3. If the user hasn't onboarded, they get a magic link to connect their Kalshi account\n4. The agent sends the message to Claude with Kalshi tools available\n5. Claude can search markets, check prices, place trades, view portfolio — all via tool use\n6. The response is sent back through Linq Blue as iMessage(s)\n\n### Everything runs locally\n\nThere is no remote database or external auth service. Everything lives on your machine (or your single deployment):\n\n- **User credentials** — Kalshi API keys are encrypted with AES-256-GCM and stored in-memory on the server process. They exist only in RAM and are lost on restart.\n- **Conversation history** — kept in-memory per chat with a 1-hour TTL. No persistence layer needed.\n- **User profiles** — names and facts Claude learns about users are stored in-memory on the server.\n- **Onboarding** — when a new user texts the bot, they receive a magic link pointing to your server's `/auth/setup` page. They paste their Kalshi API key ID and private key into the form, which submits directly to your server. Credentials never leave your infrastructure.\n\n## Project Structure\n\n```\nsrc/\n├── index.ts              # Express server, webhook handler, main flow\n├── auth/                 # Magic link onboarding, credential encryption\n│   ├── routes.ts         # /auth/setup page and credential submission\n│   ├── encryption.ts     # AES-256-GCM credential encryption\n│   ├── magicLink.ts      # Token generation and verification\n│   ├── db.ts             # In-memory user store\n│   └── userContext.ts    # Load decrypted credentials per request\n├── claude/\n│   └── client.ts         # Claude API, system prompt, Kalshi tools\n├── kalshi/\n│   ├── client.ts         # Full Kalshi REST API client\n│   ├── signing.ts        # RSA-PSS request signing\n│   └── types.ts          # Kalshi API type definitions\n├── linq/\n│   └── client.ts         # Linq Blue API (send messages, reactions, effects)\n├── state/\n│   └── conversation.ts   # Conversation history and user profiles (in-memory)\n├── utils/\n│   └── redact.ts         # Phone number redaction for logs\n└── webhook/\n    ├── handler.ts        # Webhook processing and phone filtering\n    └── types.ts          # Webhook event types\n```\n\n## Commands\n\nUsers can text these commands:\n\n| Command | Description |\n|---------|-------------|\n| `/clear` | Reset conversation history |\n| `/forget me` | Erase everything Kai knows about you |\n| `/help` | Show available commands |\n| `/portfolio` | Quick portfolio check |\n| `/markets` | Trending/active markets |\n\n## Deployment\n\n### Docker\n\n```bash\ndocker build -t kalshi-agent .\ndocker run -p 3000:3000 --env-file .env kalshi-agent\n```\n\n### Railway / Fly.io\n\nSet your environment variables in the platform dashboard and deploy. The included `Dockerfile` and `Procfile` handle the rest. Set `BASE_URL` to your deployment URL for magic links to work.\n\n## Built with\n\n- [Linq Blue](https://linqapp.com) — iMessage/RCS API\n- [Claude](https://anthropic.com) (Anthropic) — AI reasoning and tool use\n- [Kalshi API](https://kalshi.com) — prediction market trading\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinq-team%2Fkalshi-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinq-team%2Fkalshi-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinq-team%2Fkalshi-agent/lists"}