investing 0.1.147 → 0.1.148

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 +119 -64
  2. package/dist/{archiver-web.es-1hOOOgcK.js → archiver-web.es-B69gABHP.js} +1 -1
  3. package/dist/{archiver-web.es-CaGT2xEQ.cjs → archiver-web.es-fg4bLLZa.cjs} +1 -1
  4. package/dist/bookmakerAnalysis-Bfo1zUVm.js +1 -0
  5. package/dist/bookmakerAnalysis-CHn1W8uX.cjs +1 -0
  6. package/dist/callGrok-D0D7zBHK.js +1 -0
  7. package/dist/callGrok-DWO719mN.cjs +1 -0
  8. package/dist/db/index.d.ts +0 -17
  9. package/dist/db/index.d.ts.map +1 -1
  10. package/dist/db/schema.d.ts +0 -17
  11. package/dist/db/schema.d.ts.map +1 -1
  12. package/dist/events-BJOyGWeU.cjs +1 -0
  13. package/dist/events-OvBb8rgy.js +1 -0
  14. package/dist/index-D7fsk2gy.js +15 -0
  15. package/dist/index-_V1Ql5Es.cjs +13 -0
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/index.mjs +1 -1
  20. package/dist/polymarket-updown-15-limit-order-bot-DCC8HE9Z.cjs +1 -0
  21. package/dist/polymarket-updown-15-limit-order-bot-Dv5oGAF4.js +1 -0
  22. package/dist/predictos/agents/bookmaker-agent.d.ts.map +1 -0
  23. package/dist/predictos/agents/event-analysis-agent.d.ts.map +1 -0
  24. package/dist/{prediction-markets → predictos}/agents/index.d.ts +1 -5
  25. package/dist/predictos/agents/index.d.ts.map +1 -0
  26. package/dist/predictos/agents/index.js +1 -0
  27. package/dist/predictos/agents/index.mjs +1 -0
  28. package/dist/predictos/agents/mapper-agent.d.ts.map +1 -0
  29. package/dist/{prediction-markets → predictos}/agents/polyfactual-research.d.ts +1 -1
  30. package/dist/predictos/agents/polyfactual-research.d.ts.map +1 -0
  31. package/dist/predictos/agents/polymarket-position-tracker.d.ts.map +1 -0
  32. package/dist/{prediction-markets → predictos}/agents/polymarket-put-order.d.ts +1 -1
  33. package/dist/predictos/agents/polymarket-put-order.d.ts.map +1 -0
  34. package/dist/predictos/agents/polymarket-updown-15-limit-order-bot.d.ts.map +1 -0
  35. package/dist/predictos/agents/x402-seller.d.ts.map +1 -0
  36. package/dist/predictos/ai/callBlockRun.d.ts.map +1 -0
  37. package/dist/predictos/ai/callGrok.d.ts.map +1 -0
  38. package/dist/predictos/ai/callOpenAI.d.ts.map +1 -0
  39. package/dist/predictos/ai/http.d.ts.map +1 -0
  40. package/dist/{prediction-markets → predictos}/ai/index.d.ts +1 -1
  41. package/dist/predictos/ai/index.d.ts.map +1 -0
  42. package/dist/predictos/ai/index.js +1 -0
  43. package/dist/predictos/ai/index.mjs +1 -0
  44. package/dist/predictos/ai/prompts/analyzeEventMarkets.d.ts.map +1 -0
  45. package/dist/predictos/ai/prompts/arbitrageAnalysis.d.ts.map +1 -0
  46. package/dist/predictos/ai/prompts/bookmakerAnalysis.d.ts.map +1 -0
  47. package/dist/predictos/ai/prompts/searchQueryGenerator.d.ts.map +1 -0
  48. package/dist/predictos/ai/types.d.ts.map +1 -0
  49. package/dist/predictos/arbitrage.d.ts.map +1 -0
  50. package/dist/predictos/arbitrage.js +1 -0
  51. package/dist/predictos/arbitrage.mjs +1 -0
  52. package/dist/{prediction-markets → predictos}/clients/polyfactual.d.ts +1 -1
  53. package/dist/predictos/clients/polyfactual.d.ts.map +1 -0
  54. package/dist/{prediction-markets → predictos}/clients/polymarket.d.ts +1 -1
  55. package/dist/predictos/clients/polymarket.d.ts.map +1 -0
  56. package/dist/{prediction-markets → predictos}/clients/x402.d.ts +1 -1
  57. package/dist/predictos/clients/x402.d.ts.map +1 -0
  58. package/dist/{prediction-markets → predictos}/data/kalshi.d.ts +1 -1
  59. package/dist/predictos/data/kalshi.d.ts.map +1 -0
  60. package/dist/predictos/data/kalshi.js +1 -0
  61. package/dist/predictos/data/kalshi.mjs +1 -0
  62. package/dist/{prediction-markets → predictos}/data/polymarket.d.ts +1 -1
  63. package/dist/predictos/data/polymarket.d.ts.map +1 -0
  64. package/dist/predictos/data/polymarket.js +1 -0
  65. package/dist/predictos/data/polymarket.mjs +1 -0
  66. package/dist/predictos/events.d.ts.map +1 -0
  67. package/dist/{prediction-markets → predictos}/index.d.ts +5 -7
  68. package/dist/predictos/index.d.ts.map +1 -0
  69. package/dist/predictos/index.js +1 -0
  70. package/dist/predictos/index.mjs +1 -0
  71. package/dist/{prediction-markets → predictos}/types.d.ts +2 -118
  72. package/dist/predictos/types.d.ts.map +1 -0
  73. package/dist/searchQueryGenerator-DIIs9xw5.js +1 -0
  74. package/dist/searchQueryGenerator-rCVblXJS.cjs +1 -0
  75. package/dist/stocks/index.d.ts +1 -0
  76. package/dist/stocks/index.d.ts.map +1 -1
  77. package/dist/stocks/quote-cache-service.d.ts +2 -11
  78. package/dist/stocks/quote-cache-service.d.ts.map +1 -1
  79. package/dist/stocks/unified-quote-service.d.ts +6 -15
  80. package/dist/stocks/unified-quote-service.d.ts.map +1 -1
  81. package/package.json +49 -15
  82. package/dist/index-BDctGCHy.js +0 -15
  83. package/dist/index-C2kLUUjU.cjs +0 -13
  84. package/dist/prediction-markets/agents/bookmaker-agent.d.ts.map +0 -1
  85. package/dist/prediction-markets/agents/event-analysis-agent.d.ts.map +0 -1
  86. package/dist/prediction-markets/agents/index.d.ts.map +0 -1
  87. package/dist/prediction-markets/agents/kalshi-momentum-agent.d.ts +0 -4
  88. package/dist/prediction-markets/agents/kalshi-momentum-agent.d.ts.map +0 -1
  89. package/dist/prediction-markets/agents/mapper-agent.d.ts.map +0 -1
  90. package/dist/prediction-markets/agents/polyfactual-research.d.ts.map +0 -1
  91. package/dist/prediction-markets/agents/polymarket-position-tracker.d.ts.map +0 -1
  92. package/dist/prediction-markets/agents/polymarket-put-order.d.ts.map +0 -1
  93. package/dist/prediction-markets/agents/polymarket-updown-15-limit-order-bot.d.ts.map +0 -1
  94. package/dist/prediction-markets/agents/x402-seller.d.ts.map +0 -1
  95. package/dist/prediction-markets/ai/callBlockRun.d.ts.map +0 -1
  96. package/dist/prediction-markets/ai/callGrok.d.ts.map +0 -1
  97. package/dist/prediction-markets/ai/callOpenAI.d.ts.map +0 -1
  98. package/dist/prediction-markets/ai/http.d.ts.map +0 -1
  99. package/dist/prediction-markets/ai/index.d.ts.map +0 -1
  100. package/dist/prediction-markets/ai/prompts/analyzeEventMarkets.d.ts.map +0 -1
  101. package/dist/prediction-markets/ai/prompts/arbitrageAnalysis.d.ts.map +0 -1
  102. package/dist/prediction-markets/ai/prompts/bookmakerAnalysis.d.ts.map +0 -1
  103. package/dist/prediction-markets/ai/prompts/searchQueryGenerator.d.ts.map +0 -1
  104. package/dist/prediction-markets/ai/types.d.ts.map +0 -1
  105. package/dist/prediction-markets/arbitrage.d.ts.map +0 -1
  106. package/dist/prediction-markets/clients/polyfactual.d.ts.map +0 -1
  107. package/dist/prediction-markets/clients/polymarket.d.ts.map +0 -1
  108. package/dist/prediction-markets/clients/x402.d.ts.map +0 -1
  109. package/dist/prediction-markets/data/kalshi.d.ts.map +0 -1
  110. package/dist/prediction-markets/data/polymarket.d.ts.map +0 -1
  111. package/dist/prediction-markets/events.d.ts.map +0 -1
  112. package/dist/prediction-markets/execution/paper.d.ts +0 -18
  113. package/dist/prediction-markets/execution/paper.d.ts.map +0 -1
  114. package/dist/prediction-markets/index.d.ts.map +0 -1
  115. package/dist/prediction-markets/strategies/kalshi-momentum.d.ts +0 -12
  116. package/dist/prediction-markets/strategies/kalshi-momentum.d.ts.map +0 -1
  117. package/dist/prediction-markets/types.d.ts.map +0 -1
  118. /package/dist/{prediction-markets → predictos}/agents/bookmaker-agent.d.ts +0 -0
  119. /package/dist/{prediction-markets → predictos}/agents/event-analysis-agent.d.ts +0 -0
  120. /package/dist/{prediction-markets → predictos}/agents/mapper-agent.d.ts +0 -0
  121. /package/dist/{prediction-markets → predictos}/agents/polymarket-position-tracker.d.ts +0 -0
  122. /package/dist/{prediction-markets → predictos}/agents/polymarket-updown-15-limit-order-bot.d.ts +0 -0
  123. /package/dist/{prediction-markets → predictos}/agents/x402-seller.d.ts +0 -0
  124. /package/dist/{prediction-markets → predictos}/ai/callBlockRun.d.ts +0 -0
  125. /package/dist/{prediction-markets → predictos}/ai/callGrok.d.ts +0 -0
  126. /package/dist/{prediction-markets → predictos}/ai/callOpenAI.d.ts +0 -0
  127. /package/dist/{prediction-markets → predictos}/ai/http.d.ts +0 -0
  128. /package/dist/{prediction-markets → predictos}/ai/prompts/analyzeEventMarkets.d.ts +0 -0
  129. /package/dist/{prediction-markets → predictos}/ai/prompts/arbitrageAnalysis.d.ts +0 -0
  130. /package/dist/{prediction-markets → predictos}/ai/prompts/bookmakerAnalysis.d.ts +0 -0
  131. /package/dist/{prediction-markets → predictos}/ai/prompts/searchQueryGenerator.d.ts +0 -0
  132. /package/dist/{prediction-markets → predictos}/ai/types.d.ts +0 -0
  133. /package/dist/{prediction-markets → predictos}/arbitrage.d.ts +0 -0
  134. /package/dist/{prediction-markets → predictos}/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://docs.autoinvestment.broker/"><img src="https://img.shields.io/badge/Docs-blue?logo=ReadTheDocs&logoColor=white" alt="Documentation" /></a>
7
+ <a href="https://qwksearch.com/api"><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/ai-broker-investing-agent/stargazers"><img src="https://img.shields.io/github/stars/OpenSourceAGI/ai-broker-investing-agent" alt="GitHub Stars" /></a>
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>
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/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>
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>
21
21
  <br />
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>
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>
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,6 +33,8 @@ 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)
36
38
  - 🔌 **Alpaca Trading API** - Easy-to-use wrapper for Alpaca trading platform
37
39
  - 📈 **Technical Analysis** - Algorithmic trading strategies and indicators
38
40
  - 🎯 **Social Trading** - Track and analyze top traders and strategies
@@ -111,51 +113,36 @@ const leaders = await fetchLeaderboard({
111
113
  });
112
114
  ```
113
115
 
114
- ### Kalshi Momentum Paper Agent
116
+ ### PredictOS — Prediction-Market Analysis & Arbitrage
115
117
 
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.
118
+ ```typescript
119
+ import {
120
+ runEventAnalysisAgent,
121
+ findArbitrage,
122
+ getEvents,
123
+ } from "investing/predictos";
121
124
 
122
- Run the included replay from `packages/investing`:
125
+ const url = "https://polymarket.com/event/will-x-happen-by-2026";
123
126
 
124
- ```bash
125
- bun run demo:kalshi-momentum
126
- ```
127
+ // Resolve a Polymarket / Kalshi / Jupiter event URL into its raw markets
128
+ const event = await getEvents({ url });
127
129
 
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
- })),
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
138
137
  });
139
138
 
140
- console.log(result.report);
139
+ // Look for the same event mispriced on the other venue
140
+ const arb = await findArbitrage({ url, model: "grok-4-fast" });
141
141
  ```
142
142
 
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.
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.
159
146
 
160
147
  ### Trading Agents Framework
161
148
 
@@ -261,7 +248,7 @@ Get Polymarket leaderboard of top traders.
261
248
  - `limit` - Number of results (default: 20)
262
249
  - `category` - Market category (default: 'overall')
263
250
 
264
- ### Prediction-Market Agents & Arbitrage
251
+ ### PredictOS Core
265
252
 
266
253
  ```typescript
267
254
  import {
@@ -270,26 +257,80 @@ import {
270
257
  runMapperAgent,
271
258
  findArbitrage,
272
259
  getEvents,
273
- } from "investing/prediction-markets";
260
+ } from "investing/predictos";
274
261
  ```
275
262
 
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`.
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.
293
334
 
294
335
  ### Trading Agents
295
336
 
@@ -370,6 +411,12 @@ ALPACA_SECRET=your_secret_here
370
411
  # OpenAI for AI-powered analysis
371
412
  OPENAI_API_KEY=your_openai_key
372
413
 
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
+
373
420
  # Optional: Alternative LLM providers
374
421
  ANTHROPIC_API_KEY=your_anthropic_key
375
422
  GOOGLE_API_KEY=your_google_key
@@ -482,7 +529,15 @@ See the `/examples` directory for complete working examples:
482
529
 
483
530
  - [GitHub Repository](https://github.com/vtempest/ai-broker-investment-agent)
484
531
  - [Documentation](https://invest.vtempest.com/docs)
532
+ - [Agent skill](../../skills/ask-investing/SKILL.md)
485
533
  - [Examples](./examples)
486
534
 
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
+
487
542
  - [GitHub Issues](https://github.com/vtempest/ai-broker-investment-agent/issues)
488
543
  - [Documentation](https://invest.vtempest.com/docs)