investing 0.1.140 → 0.1.142

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.
Files changed (134) hide show
  1. package/README.md +64 -119
  2. package/dist/{archiver-web.es-fg4bLLZa.cjs → archiver-web.es-B_peaspB.cjs} +1 -1
  3. package/dist/{archiver-web.es-B69gABHP.js → archiver-web.es-SgFqI9XP.js} +1 -1
  4. package/dist/db/index.d.ts +17 -0
  5. package/dist/db/index.d.ts.map +1 -1
  6. package/dist/db/schema.d.ts +17 -0
  7. package/dist/db/schema.d.ts.map +1 -1
  8. package/dist/index--JDrsJ7n.cjs +13 -0
  9. package/dist/index-TqOJnUcZ.js +15 -0
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/index.mjs +1 -1
  14. package/dist/prediction-markets/agents/bookmaker-agent.d.ts.map +1 -0
  15. package/dist/prediction-markets/agents/event-analysis-agent.d.ts.map +1 -0
  16. package/dist/{predictos → prediction-markets}/agents/index.d.ts +5 -1
  17. package/dist/prediction-markets/agents/index.d.ts.map +1 -0
  18. package/dist/prediction-markets/agents/kalshi-momentum-agent.d.ts +4 -0
  19. package/dist/prediction-markets/agents/kalshi-momentum-agent.d.ts.map +1 -0
  20. package/dist/prediction-markets/agents/mapper-agent.d.ts.map +1 -0
  21. package/dist/{predictos → prediction-markets}/agents/polyfactual-research.d.ts +1 -1
  22. package/dist/prediction-markets/agents/polyfactual-research.d.ts.map +1 -0
  23. package/dist/prediction-markets/agents/polymarket-position-tracker.d.ts.map +1 -0
  24. package/dist/{predictos → prediction-markets}/agents/polymarket-put-order.d.ts +1 -1
  25. package/dist/prediction-markets/agents/polymarket-put-order.d.ts.map +1 -0
  26. package/dist/prediction-markets/agents/polymarket-updown-15-limit-order-bot.d.ts.map +1 -0
  27. package/dist/prediction-markets/agents/x402-seller.d.ts.map +1 -0
  28. package/dist/prediction-markets/ai/callBlockRun.d.ts.map +1 -0
  29. package/dist/prediction-markets/ai/callGrok.d.ts.map +1 -0
  30. package/dist/prediction-markets/ai/callOpenAI.d.ts.map +1 -0
  31. package/dist/prediction-markets/ai/http.d.ts.map +1 -0
  32. package/dist/{predictos → prediction-markets}/ai/index.d.ts +1 -1
  33. package/dist/prediction-markets/ai/index.d.ts.map +1 -0
  34. package/dist/prediction-markets/ai/prompts/analyzeEventMarkets.d.ts.map +1 -0
  35. package/dist/prediction-markets/ai/prompts/arbitrageAnalysis.d.ts.map +1 -0
  36. package/dist/prediction-markets/ai/prompts/bookmakerAnalysis.d.ts.map +1 -0
  37. package/dist/prediction-markets/ai/prompts/searchQueryGenerator.d.ts.map +1 -0
  38. package/dist/prediction-markets/ai/types.d.ts.map +1 -0
  39. package/dist/prediction-markets/arbitrage.d.ts.map +1 -0
  40. package/dist/{predictos → prediction-markets}/clients/polyfactual.d.ts +1 -1
  41. package/dist/prediction-markets/clients/polyfactual.d.ts.map +1 -0
  42. package/dist/{predictos → prediction-markets}/clients/polymarket.d.ts +1 -1
  43. package/dist/prediction-markets/clients/polymarket.d.ts.map +1 -0
  44. package/dist/{predictos → prediction-markets}/clients/x402.d.ts +1 -1
  45. package/dist/prediction-markets/clients/x402.d.ts.map +1 -0
  46. package/dist/{predictos → prediction-markets}/data/kalshi.d.ts +1 -1
  47. package/dist/prediction-markets/data/kalshi.d.ts.map +1 -0
  48. package/dist/{predictos → prediction-markets}/data/polymarket.d.ts +1 -1
  49. package/dist/prediction-markets/data/polymarket.d.ts.map +1 -0
  50. package/dist/prediction-markets/events.d.ts.map +1 -0
  51. package/dist/prediction-markets/execution/paper.d.ts +18 -0
  52. package/dist/prediction-markets/execution/paper.d.ts.map +1 -0
  53. package/dist/{predictos → prediction-markets}/index.d.ts +7 -5
  54. package/dist/prediction-markets/index.d.ts.map +1 -0
  55. package/dist/prediction-markets/strategies/kalshi-momentum.d.ts +12 -0
  56. package/dist/prediction-markets/strategies/kalshi-momentum.d.ts.map +1 -0
  57. package/dist/{predictos → prediction-markets}/types.d.ts +118 -2
  58. package/dist/prediction-markets/types.d.ts.map +1 -0
  59. package/dist/stocks/index.d.ts +0 -1
  60. package/dist/stocks/index.d.ts.map +1 -1
  61. package/dist/stocks/quote-cache-service.d.ts +11 -2
  62. package/dist/stocks/quote-cache-service.d.ts.map +1 -1
  63. package/dist/stocks/unified-quote-service.d.ts +15 -6
  64. package/dist/stocks/unified-quote-service.d.ts.map +1 -1
  65. package/package.json +15 -49
  66. package/dist/bookmakerAnalysis-Bfo1zUVm.js +0 -1
  67. package/dist/bookmakerAnalysis-CHn1W8uX.cjs +0 -1
  68. package/dist/callGrok-D0D7zBHK.js +0 -1
  69. package/dist/callGrok-DWO719mN.cjs +0 -1
  70. package/dist/events-BJOyGWeU.cjs +0 -1
  71. package/dist/events-OvBb8rgy.js +0 -1
  72. package/dist/index-D7fsk2gy.js +0 -15
  73. package/dist/index-_V1Ql5Es.cjs +0 -13
  74. package/dist/polymarket-updown-15-limit-order-bot-DCC8HE9Z.cjs +0 -1
  75. package/dist/polymarket-updown-15-limit-order-bot-Dv5oGAF4.js +0 -1
  76. package/dist/predictos/agents/bookmaker-agent.d.ts.map +0 -1
  77. package/dist/predictos/agents/event-analysis-agent.d.ts.map +0 -1
  78. package/dist/predictos/agents/index.d.ts.map +0 -1
  79. package/dist/predictos/agents/index.js +0 -1
  80. package/dist/predictos/agents/index.mjs +0 -1
  81. package/dist/predictos/agents/mapper-agent.d.ts.map +0 -1
  82. package/dist/predictos/agents/polyfactual-research.d.ts.map +0 -1
  83. package/dist/predictos/agents/polymarket-position-tracker.d.ts.map +0 -1
  84. package/dist/predictos/agents/polymarket-put-order.d.ts.map +0 -1
  85. package/dist/predictos/agents/polymarket-updown-15-limit-order-bot.d.ts.map +0 -1
  86. package/dist/predictos/agents/x402-seller.d.ts.map +0 -1
  87. package/dist/predictos/ai/callBlockRun.d.ts.map +0 -1
  88. package/dist/predictos/ai/callGrok.d.ts.map +0 -1
  89. package/dist/predictos/ai/callOpenAI.d.ts.map +0 -1
  90. package/dist/predictos/ai/http.d.ts.map +0 -1
  91. package/dist/predictos/ai/index.d.ts.map +0 -1
  92. package/dist/predictos/ai/index.js +0 -1
  93. package/dist/predictos/ai/index.mjs +0 -1
  94. package/dist/predictos/ai/prompts/analyzeEventMarkets.d.ts.map +0 -1
  95. package/dist/predictos/ai/prompts/arbitrageAnalysis.d.ts.map +0 -1
  96. package/dist/predictos/ai/prompts/bookmakerAnalysis.d.ts.map +0 -1
  97. package/dist/predictos/ai/prompts/searchQueryGenerator.d.ts.map +0 -1
  98. package/dist/predictos/ai/types.d.ts.map +0 -1
  99. package/dist/predictos/arbitrage.d.ts.map +0 -1
  100. package/dist/predictos/arbitrage.js +0 -1
  101. package/dist/predictos/arbitrage.mjs +0 -1
  102. package/dist/predictos/clients/polyfactual.d.ts.map +0 -1
  103. package/dist/predictos/clients/polymarket.d.ts.map +0 -1
  104. package/dist/predictos/clients/x402.d.ts.map +0 -1
  105. package/dist/predictos/data/kalshi.d.ts.map +0 -1
  106. package/dist/predictos/data/kalshi.js +0 -1
  107. package/dist/predictos/data/kalshi.mjs +0 -1
  108. package/dist/predictos/data/polymarket.d.ts.map +0 -1
  109. package/dist/predictos/data/polymarket.js +0 -1
  110. package/dist/predictos/data/polymarket.mjs +0 -1
  111. package/dist/predictos/events.d.ts.map +0 -1
  112. package/dist/predictos/index.d.ts.map +0 -1
  113. package/dist/predictos/index.js +0 -1
  114. package/dist/predictos/index.mjs +0 -1
  115. package/dist/predictos/types.d.ts.map +0 -1
  116. package/dist/searchQueryGenerator-DIIs9xw5.js +0 -1
  117. package/dist/searchQueryGenerator-rCVblXJS.cjs +0 -1
  118. /package/dist/{predictos → prediction-markets}/agents/bookmaker-agent.d.ts +0 -0
  119. /package/dist/{predictos → prediction-markets}/agents/event-analysis-agent.d.ts +0 -0
  120. /package/dist/{predictos → prediction-markets}/agents/mapper-agent.d.ts +0 -0
  121. /package/dist/{predictos → prediction-markets}/agents/polymarket-position-tracker.d.ts +0 -0
  122. /package/dist/{predictos → prediction-markets}/agents/polymarket-updown-15-limit-order-bot.d.ts +0 -0
  123. /package/dist/{predictos → prediction-markets}/agents/x402-seller.d.ts +0 -0
  124. /package/dist/{predictos → prediction-markets}/ai/callBlockRun.d.ts +0 -0
  125. /package/dist/{predictos → prediction-markets}/ai/callGrok.d.ts +0 -0
  126. /package/dist/{predictos → prediction-markets}/ai/callOpenAI.d.ts +0 -0
  127. /package/dist/{predictos → prediction-markets}/ai/http.d.ts +0 -0
  128. /package/dist/{predictos → prediction-markets}/ai/prompts/analyzeEventMarkets.d.ts +0 -0
  129. /package/dist/{predictos → prediction-markets}/ai/prompts/arbitrageAnalysis.d.ts +0 -0
  130. /package/dist/{predictos → prediction-markets}/ai/prompts/bookmakerAnalysis.d.ts +0 -0
  131. /package/dist/{predictos → prediction-markets}/ai/prompts/searchQueryGenerator.d.ts +0 -0
  132. /package/dist/{predictos → prediction-markets}/ai/types.d.ts +0 -0
  133. /package/dist/{predictos → prediction-markets}/arbitrage.d.ts +0 -0
  134. /package/dist/{predictos → prediction-markets}/events.d.ts +0 -0
package/README.md CHANGED
@@ -4,22 +4,22 @@
4
4
 
5
5
  <!-- template-git-repo:badges:start -->
6
6
  <p align="center">
7
- <a href="https://qwksearch.com/api"><img src="https://img.shields.io/badge/Docs-blue?logo=ReadTheDocs&logoColor=white" alt="Documentation" /></a>
7
+ <a href="https://docs.autoinvestment.broker/"><img src="https://img.shields.io/badge/Docs-blue?logo=ReadTheDocs&logoColor=white" alt="Documentation" /></a>
8
8
  <br />
9
- <a href="https://github.com/OpenSourceAGI/qwksearch-research-agent/stargazers"><img src="https://img.shields.io/github/stars/OpenSourceAGI/qwksearch-research-agent" alt="GitHub Stars" /></a>
9
+ <a href="https://github.com/OpenSourceAGI/ai-broker-investing-agent/stargazers"><img src="https://img.shields.io/github/stars/OpenSourceAGI/ai-broker-investing-agent" alt="GitHub Stars" /></a>
10
10
  <a href="https://www.npmjs.com/package/investing"><img src="https://img.shields.io/npm/dm/investing.svg" alt="NPM Monthly Downloads" /></a>
11
11
  <a href="https://www.npmjs.com/package/investing"><img src="https://img.shields.io/npm/v/investing.svg" alt="npm version" /></a>
12
12
  <a href="https://www.npmjs.com/package/investing"><img src="https://img.shields.io/npm/dt/investing.svg" alt="NPM Total Downloads" /></a>
13
13
  <a href="https://www.npmjs.com/package/investing"><img src="https://img.shields.io/npm/types/investing" alt="TypeScript types" /></a>
14
14
  <a href="https://packagephobia.com/result?p=investing"><img src="https://packagephobia.com/badge?p=investing" alt="Install size" /></a>
15
15
  <br />
16
- <a href="https://github.com/OpenSourceAGI/qwksearch-research-agent/issues"><img src="https://img.shields.io/github/issues/OpenSourceAGI/qwksearch-research-agent?logo=github" alt="GitHub Issues" /></a>
17
- <a href="https://github.com/OpenSourceAGI/qwksearch-research-agent/pulls"><img src="https://img.shields.io/github/issues-pr/OpenSourceAGI/qwksearch-research-agent?logo=github&label=PRs" alt="Open Pull Requests" /></a>
18
- <a href="https://github.com/OpenSourceAGI/qwksearch-research-agent/pulls?q=is%3Apr+is%3Aclosed"><img src="https://img.shields.io/github/issues-pr-closed/OpenSourceAGI/qwksearch-research-agent?logo=github&label=PRs%20merged&color=8957e5" alt="Merged Pull Requests" /></a>
19
- <a href="https://github.com/OpenSourceAGI/qwksearch-research-agent/discussions"><img src="https://img.shields.io/github/discussions/OpenSourceAGI/qwksearch-research-agent" alt="GitHub Discussions" /></a>
20
- <a href="https://github.com/OpenSourceAGI/qwksearch-research-agent/commits/master/"><img src="https://img.shields.io/github/last-commit/OpenSourceAGI/qwksearch-research-agent.svg" alt="GitHub last commit" /></a>
16
+ <a href="https://github.com/OpenSourceAGI/ai-broker-investing-agent/issues"><img src="https://img.shields.io/github/issues/OpenSourceAGI/ai-broker-investing-agent?logo=github" alt="GitHub Issues" /></a>
17
+ <a href="https://github.com/OpenSourceAGI/ai-broker-investing-agent/pulls"><img src="https://img.shields.io/github/issues-pr/OpenSourceAGI/ai-broker-investing-agent?logo=github&label=PRs" alt="Open Pull Requests" /></a>
18
+ <a href="https://github.com/OpenSourceAGI/ai-broker-investing-agent/pulls?q=is%3Apr+is%3Aclosed"><img src="https://img.shields.io/github/issues-pr-closed/OpenSourceAGI/ai-broker-investing-agent?logo=github&label=PRs%20merged&color=8957e5" alt="Merged Pull Requests" /></a>
19
+ <a href="https://github.com/OpenSourceAGI/ai-broker-investing-agent/discussions"><img src="https://img.shields.io/github/discussions/OpenSourceAGI/ai-broker-investing-agent" alt="GitHub Discussions" /></a>
20
+ <a href="https://github.com/OpenSourceAGI/ai-broker-investing-agent/commits/main/"><img src="https://img.shields.io/github/last-commit/OpenSourceAGI/ai-broker-investing-agent.svg" alt="GitHub last commit" /></a>
21
21
  <br />
22
- <a href="https://stackblitz.com/github/OpenSourceAGI/qwksearch-research-agent/tree/master/packages/investing"><img height="20px" src="https://developer.stackblitz.com/img/open_in_stackblitz.svg" alt="Open in StackBlitz" /></a>
22
+ <a href="https://stackblitz.com/github/OpenSourceAGI/ai-broker-investing-agent/tree/main/packages/investing"><img height="20px" src="https://developer.stackblitz.com/img/open_in_stackblitz.svg" alt="Open in StackBlitz" /></a>
23
23
  <img src="https://img.shields.io/badge/Bun-14151A?logo=bun&logoColor=white" alt="Bun" /> <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white" alt="TypeScript" /> <img src="https://img.shields.io/badge/Drizzle%20ORM-C5F74F?logo=drizzle&logoColor=white" alt="Drizzle ORM" /> <img src="https://img.shields.io/badge/Zod-3E67B1?logo=zod&logoColor=white" alt="Zod" /> <img src="https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white" alt="Vite" /> <img src="https://img.shields.io/badge/Vitest-6E9F18?logo=vitest&logoColor=white" alt="Vitest" />
24
24
  </p>
25
25
  <!-- template-git-repo:badges:end -->
@@ -33,8 +33,6 @@ A comprehensive TypeScript/JavaScript library for investment analysis, trading a
33
33
  - 🤖 **Trading Agents** - Multi-agent framework for automated trading strategies
34
34
  - 📊 **Stock Data** - Fetch and analyze stock data from Yahoo Finance, SEC filings, and more
35
35
  - 💹 **Prediction Markets** - Polymarket integration for prediction market data
36
- - 🔮 **PredictOS Core** - Multi-agent prediction-market analysis, Kalshi/Polymarket
37
- data clients, and cross-platform arbitrage (merged in from the `predictos` package)
38
36
  - 🔌 **Alpaca Trading API** - Easy-to-use wrapper for Alpaca trading platform
39
37
  - 📈 **Technical Analysis** - Algorithmic trading strategies and indicators
40
38
  - 🎯 **Social Trading** - Track and analyze top traders and strategies
@@ -113,36 +111,51 @@ const leaders = await fetchLeaderboard({
113
111
  });
114
112
  ```
115
113
 
116
- ### PredictOS — Prediction-Market Analysis & Arbitrage
114
+ ### Kalshi Momentum Paper Agent
117
115
 
118
- ```typescript
119
- import {
120
- runEventAnalysisAgent,
121
- findArbitrage,
122
- getEvents,
123
- } from "investing/predictos";
116
+ The prediction-markets package includes a deterministic TypeScript port of the
117
+ momentum rules from PyKalshi's MIT-licensed
118
+ `kalshi-bot-api/examples/momentum_bot.py`. It consumes recorded ticks and uses
119
+ an in-memory paper executor, so it never connects to Kalshi, submits orders, or
120
+ requires credentials.
124
121
 
125
- const url = "https://polymarket.com/event/will-x-happen-by-2026";
122
+ Run the included replay from `packages/investing`:
126
123
 
127
- // Resolve a Polymarket / Kalshi / Jupiter event URL into its raw markets
128
- const event = await getEvents({ url });
124
+ ```bash
125
+ bun run demo:kalshi-momentum
126
+ ```
129
127
 
130
- // Analyze those markets for alpha and a predicted winner
131
- const { analysis } = await runEventAnalysisAgent({
132
- markets: event.markets,
133
- eventIdentifier: event.eventIdentifier,
134
- pmType: event.pmType,
135
- model: "grok-4-fast",
136
- tools: ["x_search"], // Grok models only
128
+ ```typescript
129
+ import { runKalshiMomentumPaperAgent } from "investing/prediction-markets";
130
+
131
+ const result = runKalshiMomentumPaperAgent({
132
+ initialCashCents: 10_000,
133
+ ticks: [50, 51, 52, 53, 58].map((yesPriceCents, index) => ({
134
+ ticker: "DEMO-KALSHI-MARKET",
135
+ timestamp: new Date(Date.UTC(2026, 0, 1, 0, index)).toISOString(),
136
+ yesPriceCents,
137
+ })),
137
138
  });
138
139
 
139
- // Look for the same event mispriced on the other venue
140
- const arb = await findArbitrage({ url, model: "grok-4-fast" });
140
+ console.log(result.report);
141
141
  ```
142
142
 
143
- Every entry point takes a typed `request` object and an optional second
144
- `config` (`AIConfig` / `DataConfig`) that falls back to `process.env`. Missing
145
- required fields **throw** rather than returning an error result.
143
+ Prices are integer cents per contract. A YES tick of `53` implies a NO price
144
+ of `47`. Trade `action` (`BUY`, `SELL`, `HOLD`) is separate from the binary
145
+ `outcome` (`YES`, `NO`): selling YES closes YES contracts and does not mean
146
+ buying NO.
147
+
148
+ Configuration controls `lookback`, `momentumThreshold`, `positionSize`,
149
+ `profitTargetCents`, `stopLossCents`, and `maxPosition`. The defaults preserve
150
+ the upstream example: three consecutive moves, 10 contracts, a 5-cent target,
151
+ a 3-cent stop, and a 50-contract limit. The paper executor fills immediately at
152
+ the recorded outcome price with no fees or slippage and reports cash, open
153
+ positions, and realized/unrealized P&L.
154
+
155
+ This replay is a strategy demonstration, not a backtest or live execution
156
+ system. It assumes complementary YES/NO prices, does not model an order book,
157
+ partial fills, fees, latency, settlement, or market resolution, and does not
158
+ enable the existing unimplemented Kalshi live mapper.
146
159
 
147
160
  ### Trading Agents Framework
148
161
 
@@ -248,7 +261,7 @@ Get Polymarket leaderboard of top traders.
248
261
  - `limit` - Number of results (default: 20)
249
262
  - `category` - Market category (default: 'overall')
250
263
 
251
- ### PredictOS Core
264
+ ### Prediction-Market Agents & Arbitrage
252
265
 
253
266
  ```typescript
254
267
  import {
@@ -257,80 +270,26 @@ import {
257
270
  runMapperAgent,
258
271
  findArbitrage,
259
272
  getEvents,
260
- } from "investing/predictos";
273
+ } from "investing/prediction-markets";
261
274
  ```
262
275
 
263
- > Adapted from [PredictOS](https://github.com/PredictionXBT/PredictOS) by
264
- > **PredictionXBT** (MIT licensed, © 2025). The original code shipped as
265
- > Deno/Supabase edge functions; here it is refactored into plain, typed,
266
- > dependency-light library functions with no HTTP/CORS layer. It lived in a
267
- > sibling `predictos` package until that package was merged into `investing`.
268
- > See [`NOTICE`](./NOTICE) and
269
- > [`LICENSE-PredictOS-MIT`](./LICENSE-PredictOS-MIT).
270
-
271
- #### What it covers
272
-
273
- - **AI provider clients** — OpenAI (Responses API), Grok/xAI (Responses API,
274
- with optional `x_search` / `web_search` tools), and BlockRun (x402
275
- wallet-based micropayments across 20+ models), plus the analysis prompt
276
- builders (`analyzeEventMarkets`, `bookmakerAnalysis`, `arbitrageAnalysis`,
277
- `searchQueryGenerator`).
278
- - **Market data clients** — Kalshi via the DFlow API
279
- (`investing/predictos/data/kalshi`) and Polymarket via the Dome API
280
- (`investing/predictos/data/polymarket`).
281
- - **Multi-agent pipeline** (`investing/predictos/agents`):
282
- - `runEventAnalysisAgent` — analyzes an event's markets for alpha and a
283
- predicted winner.
284
- - `runBookmakerAgent` — aggregates multiple agent analyses (and optional
285
- external data sources) into a single consolidated assessment.
286
- - `runMapperAgent` — turns an analysis into Polymarket order parameters
287
- (pure logic; Kalshi mapping not yet implemented).
288
- - **Cross-platform arbitrage** (`investing/predictos/arbitrage`) —
289
- `findArbitrage` parses a Polymarket/Kalshi URL, generates a search query with
290
- AI, searches the other platform, and evaluates whether the same event is
291
- mispriced across venues.
292
- - **Event fetching** (`getEvents`) — resolves a Polymarket/Kalshi/Jupiter URL
293
- into its raw markets (Kalshi via DFlow, Polymarket via the Gamma API).
294
-
295
- #### Subpath exports
296
-
297
- | Import | Contents |
298
- | --- | --- |
299
- | `investing/predictos` | Everything (barrel) |
300
- | `investing/predictos/ai` | AI clients + prompt builders |
301
- | `investing/predictos/data/kalshi` | Kalshi (DFlow) data client |
302
- | `investing/predictos/data/polymarket` | Polymarket (Dome) data client |
303
- | `investing/predictos/agents` | `runEventAnalysisAgent`, `runBookmakerAgent`, `runMapperAgent` |
304
- | `investing/predictos/arbitrage` | `findArbitrage` |
305
-
306
- The barrel re-exports the Kalshi (DFlow) client at the top level. The Polymarket
307
- (Dome) client exposes Kalshi helpers under the same names, so the barrel renames
308
- those two to `getDomeKalshiMarketsByEvent` / `buildDomeKalshiMarketUrl` — import
309
- from `investing/predictos/data/polymarket` for their original names. The
310
- Gamma/CLOB trading client, Polyfactual and x402 are namespaced on the barrel as
311
- `polymarketClob`, `polyfactual` and `x402` for the same reason.
312
-
313
- #### Refactor notes (Deno → Node)
314
-
315
- - Deno HTTP handlers (`Deno.serve`, `new Response(...)`, CORS headers) were
316
- removed. Each endpoint is now a plain exported async function taking typed
317
- parameters and returning a typed result; validation failures `throw`.
318
- - `Deno.env.get("X")` was replaced with config/options objects
319
- (`AIConfig`, `DataConfig`, per-call `apiKey`/`walletKey`) that fall back to
320
- `process.env` (`OPENAI_API_KEY`, `XAI_API_KEY`, `BLOCKRUN_WALLET_KEY`,
321
- `DOME_API_KEY`, `DFLOW_API_KEY`). No secrets are hardcoded.
322
- - Remote (`https://...`) and `npm:` import specifiers were replaced with normal
323
- package imports (`ethers`). The global `fetch` (Node 18+) is used throughout.
324
- - Prompt text and analysis logic are preserved verbatim.
325
-
326
- #### Not ported (yet)
327
-
328
- Intentionally left out of the core port — noted for future work: the Next.js
329
- `terminal/` frontend, the Python alpha-hunter examples, the **pay.sh** payment
330
- serving flows, **Irys** verifiable-agent storage, wallet-tracking websockets, and
331
- on-chain order execution (the mapper produces order parameters, but placing
332
- orders is out of scope). The BlockRun client *is* ported (it only needs `ethers`
333
- + `fetch`), but its on-chain micropayment flow is untested in this environment.
276
+ Multi-agent analysis over Polymarket and Kalshi, refactored from Deno/Supabase
277
+ edge functions into plain typed async functions (MIT, see
278
+ `src/prediction-markets/LICENSE`):
279
+
280
+ - **AI clients** — OpenAI, Grok/xAI and BlockRun (x402 micropayments), plus the
281
+ analysis prompt builders.
282
+ - **Market data** — Kalshi via DFlow and Polymarket via Dome/Gamma.
283
+ - `runEventAnalysisAgent` — analyzes an event's markets for alpha and a
284
+ predicted winner.
285
+ - `runBookmakerAgent` — aggregates several agent analyses into one assessment.
286
+ - `runMapperAgent` — turns an analysis into Polymarket order parameters.
287
+ - `findArbitrage` — finds the same event on the other venue and checks whether
288
+ it is mispriced across venues.
289
+ - `getEvents` — resolves a Polymarket/Kalshi URL into its raw markets.
290
+
291
+ Keys are read from options, falling back to `OPENAI_API_KEY`, `XAI_API_KEY`,
292
+ `BLOCKRUN_WALLET_KEY`, `DOME_API_KEY` and `DFLOW_API_KEY`.
334
293
 
335
294
  ### Trading Agents
336
295
 
@@ -411,12 +370,6 @@ ALPACA_SECRET=your_secret_here
411
370
  # OpenAI for AI-powered analysis
412
371
  OPENAI_API_KEY=your_openai_key
413
372
 
414
- # PredictOS: prediction-market analysis and data
415
- XAI_API_KEY=your_xai_key # Grok/xAI
416
- BLOCKRUN_WALLET_KEY=your_wallet_key # BlockRun x402 micropayments
417
- DOME_API_KEY=your_dome_key # Polymarket market data
418
- DFLOW_API_KEY=your_dflow_key # Kalshi market data
419
-
420
373
  # Optional: Alternative LLM providers
421
374
  ANTHROPIC_API_KEY=your_anthropic_key
422
375
  GOOGLE_API_KEY=your_google_key
@@ -529,15 +482,7 @@ See the `/examples` directory for complete working examples:
529
482
 
530
483
  - [GitHub Repository](https://github.com/vtempest/ai-broker-investment-agent)
531
484
  - [Documentation](https://invest.vtempest.com/docs)
532
- - [Agent skill](../../skills/ask-investing/SKILL.md)
533
485
  - [Examples](./examples)
534
486
 
535
- ## Credits
536
-
537
- The `predictos` module is a derivative work of
538
- [PredictOS](https://github.com/PredictionXBT/PredictOS) — all original design and
539
- logic © 2025 PredictionXBT, MIT licensed. See [`NOTICE`](./NOTICE) and
540
- [`LICENSE-PredictOS-MIT`](./LICENSE-PredictOS-MIT).
541
-
542
487
  - [GitHub Issues](https://github.com/vtempest/ai-broker-investment-agent/issues)
543
488
  - [Documentation](https://invest.vtempest.com/docs)