investing 0.1.16 → 0.1.18

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 (88) hide show
  1. package/LICENSE-PredictOS-MIT +22 -0
  2. package/NOTICE +10 -0
  3. package/README.md +131 -0
  4. package/dist/{archiver-web.es-EPYdovFt.js → archiver-web.es-B69gABHP.js} +1 -1
  5. package/dist/{archiver-web.es-BgXzilRH.cjs → archiver-web.es-fg4bLLZa.cjs} +1 -1
  6. package/dist/bookmakerAnalysis-Bfo1zUVm.js +1 -0
  7. package/dist/bookmakerAnalysis-CHn1W8uX.cjs +1 -0
  8. package/dist/callGrok-D0D7zBHK.js +1 -0
  9. package/dist/callGrok-DWO719mN.cjs +1 -0
  10. package/dist/events-BJOyGWeU.cjs +1 -0
  11. package/dist/events-OvBb8rgy.js +1 -0
  12. package/dist/{index-C9OpAHBe.js → index-D7fsk2gy.js} +2 -2
  13. package/dist/{index-CcyBsxYm.cjs → index-_V1Ql5Es.cjs} +2 -2
  14. package/dist/index.js +1 -1
  15. package/dist/index.mjs +1 -1
  16. package/dist/polymarket-updown-15-limit-order-bot-DCC8HE9Z.cjs +1 -0
  17. package/dist/polymarket-updown-15-limit-order-bot-Dv5oGAF4.js +1 -0
  18. package/dist/predictos/agents/bookmaker-agent.d.ts +8 -0
  19. package/dist/predictos/agents/bookmaker-agent.d.ts.map +1 -0
  20. package/dist/predictos/agents/event-analysis-agent.d.ts +8 -0
  21. package/dist/predictos/agents/event-analysis-agent.d.ts.map +1 -0
  22. package/dist/predictos/agents/index.d.ts +21 -0
  23. package/dist/predictos/agents/index.d.ts.map +1 -0
  24. package/dist/predictos/agents/index.js +1 -0
  25. package/dist/predictos/agents/index.mjs +1 -0
  26. package/dist/predictos/agents/mapper-agent.d.ts +17 -0
  27. package/dist/predictos/agents/mapper-agent.d.ts.map +1 -0
  28. package/dist/predictos/agents/polyfactual-research.d.ts +47 -0
  29. package/dist/predictos/agents/polyfactual-research.d.ts.map +1 -0
  30. package/dist/predictos/agents/polymarket-position-tracker.d.ts +31 -0
  31. package/dist/predictos/agents/polymarket-position-tracker.d.ts.map +1 -0
  32. package/dist/predictos/agents/polymarket-put-order.d.ts +88 -0
  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 +92 -0
  35. package/dist/predictos/agents/polymarket-updown-15-limit-order-bot.d.ts.map +1 -0
  36. package/dist/predictos/agents/x402-seller.d.ts +34 -0
  37. package/dist/predictos/agents/x402-seller.d.ts.map +1 -0
  38. package/dist/predictos/ai/callBlockRun.d.ts +54 -0
  39. package/dist/predictos/ai/callBlockRun.d.ts.map +1 -0
  40. package/dist/predictos/ai/callGrok.d.ts +22 -0
  41. package/dist/predictos/ai/callGrok.d.ts.map +1 -0
  42. package/dist/predictos/ai/callOpenAI.d.ts +19 -0
  43. package/dist/predictos/ai/callOpenAI.d.ts.map +1 -0
  44. package/dist/predictos/ai/http.d.ts +19 -0
  45. package/dist/predictos/ai/http.d.ts.map +1 -0
  46. package/dist/predictos/ai/index.d.ts +19 -0
  47. package/dist/predictos/ai/index.d.ts.map +1 -0
  48. package/dist/predictos/ai/index.js +1 -0
  49. package/dist/predictos/ai/index.mjs +1 -0
  50. package/dist/predictos/ai/prompts/analyzeEventMarkets.d.ts +12 -0
  51. package/dist/predictos/ai/prompts/analyzeEventMarkets.d.ts.map +1 -0
  52. package/dist/predictos/ai/prompts/arbitrageAnalysis.d.ts +14 -0
  53. package/dist/predictos/ai/prompts/arbitrageAnalysis.d.ts.map +1 -0
  54. package/dist/predictos/ai/prompts/bookmakerAnalysis.d.ts +17 -0
  55. package/dist/predictos/ai/prompts/bookmakerAnalysis.d.ts.map +1 -0
  56. package/dist/predictos/ai/prompts/searchQueryGenerator.d.ts +18 -0
  57. package/dist/predictos/ai/prompts/searchQueryGenerator.d.ts.map +1 -0
  58. package/dist/predictos/ai/types.d.ts +214 -0
  59. package/dist/predictos/ai/types.d.ts.map +1 -0
  60. package/dist/predictos/arbitrage.d.ts +8 -0
  61. package/dist/predictos/arbitrage.d.ts.map +1 -0
  62. package/dist/predictos/arbitrage.js +1 -0
  63. package/dist/predictos/arbitrage.mjs +1 -0
  64. package/dist/predictos/clients/polyfactual.d.ts +72 -0
  65. package/dist/predictos/clients/polyfactual.d.ts.map +1 -0
  66. package/dist/predictos/clients/polymarket.d.ts +283 -0
  67. package/dist/predictos/clients/polymarket.d.ts.map +1 -0
  68. package/dist/predictos/clients/x402.d.ts +213 -0
  69. package/dist/predictos/clients/x402.d.ts.map +1 -0
  70. package/dist/predictos/data/kalshi.d.ts +66 -0
  71. package/dist/predictos/data/kalshi.d.ts.map +1 -0
  72. package/dist/predictos/data/kalshi.js +1 -0
  73. package/dist/predictos/data/kalshi.mjs +1 -0
  74. package/dist/predictos/data/polymarket.d.ts +105 -0
  75. package/dist/predictos/data/polymarket.d.ts.map +1 -0
  76. package/dist/predictos/data/polymarket.js +1 -0
  77. package/dist/predictos/data/polymarket.mjs +1 -0
  78. package/dist/predictos/events.d.ts +9 -0
  79. package/dist/predictos/events.d.ts.map +1 -0
  80. package/dist/predictos/index.d.ts +22 -7
  81. package/dist/predictos/index.d.ts.map +1 -1
  82. package/dist/predictos/index.js +1 -0
  83. package/dist/predictos/index.mjs +1 -0
  84. package/dist/predictos/types.d.ts +408 -0
  85. package/dist/predictos/types.d.ts.map +1 -0
  86. package/dist/searchQueryGenerator-DIIs9xw5.js +1 -0
  87. package/dist/searchQueryGenerator-rCVblXJS.cjs +1 -0
  88. package/package.json +44 -5
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 PredictionXBT
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/NOTICE ADDED
@@ -0,0 +1,10 @@
1
+ Adapted from PredictOS by PredictionXBT (https://github.com/PredictionXBT/PredictOS), MIT licensed.
2
+ Refactored from Deno/Supabase edge functions to Node/TypeScript ESM.
3
+
4
+ The adapted code lives in src/predictos/ and is published on the `investing/predictos`
5
+ subpath exports. It shipped as a separate `predictos` package until that package was
6
+ merged into `investing`.
7
+
8
+ The original MIT license text is kept verbatim in LICENSE-PredictOS-MIT and applies to
9
+ everything under src/predictos/. The rest of this package is licensed under
10
+ rights.institute/prosper.
package/README.md CHANGED
@@ -39,6 +39,8 @@ A comprehensive TypeScript/JavaScript library for investment analysis, trading a
39
39
  - 🤖 **Trading Agents** - Multi-agent framework for automated trading strategies
40
40
  - 📊 **Stock Data** - Fetch and analyze stock data from Yahoo Finance, SEC filings, and more
41
41
  - 💹 **Prediction Markets** - Polymarket integration for prediction market data
42
+ - 🔮 **PredictOS Core** - Multi-agent prediction-market analysis, Kalshi/Polymarket
43
+ data clients, and cross-platform arbitrage (merged in from the `predictos` package)
42
44
  - 🔌 **Alpaca Trading API** - Easy-to-use wrapper for Alpaca trading platform
43
45
  - 📈 **Technical Analysis** - Algorithmic trading strategies and indicators
44
46
  - 🎯 **Social Trading** - Track and analyze top traders and strategies
@@ -117,6 +119,37 @@ const leaders = await fetchLeaderboard({
117
119
  });
118
120
  ```
119
121
 
122
+ ### PredictOS — Prediction-Market Analysis & Arbitrage
123
+
124
+ ```typescript
125
+ import {
126
+ runEventAnalysisAgent,
127
+ findArbitrage,
128
+ getEvents,
129
+ } from "investing/predictos";
130
+
131
+ const url = "https://polymarket.com/event/will-x-happen-by-2026";
132
+
133
+ // Resolve a Polymarket / Kalshi / Jupiter event URL into its raw markets
134
+ const event = await getEvents({ url });
135
+
136
+ // Analyze those markets for alpha and a predicted winner
137
+ const { analysis } = await runEventAnalysisAgent({
138
+ markets: event.markets,
139
+ eventIdentifier: event.eventIdentifier,
140
+ pmType: event.pmType,
141
+ model: "grok-4-fast",
142
+ tools: ["x_search"], // Grok models only
143
+ });
144
+
145
+ // Look for the same event mispriced on the other venue
146
+ const arb = await findArbitrage({ url, model: "grok-4-fast" });
147
+ ```
148
+
149
+ Every entry point takes a typed `request` object and an optional second
150
+ `config` (`AIConfig` / `DataConfig`) that falls back to `process.env`. Missing
151
+ required fields **throw** rather than returning an error result.
152
+
120
153
  ### Trading Agents Framework
121
154
 
122
155
  ```typescript
@@ -221,6 +254,90 @@ Get Polymarket leaderboard of top traders.
221
254
  - `limit` - Number of results (default: 20)
222
255
  - `category` - Market category (default: 'overall')
223
256
 
257
+ ### PredictOS Core
258
+
259
+ ```typescript
260
+ import {
261
+ runEventAnalysisAgent,
262
+ runBookmakerAgent,
263
+ runMapperAgent,
264
+ findArbitrage,
265
+ getEvents,
266
+ } from "investing/predictos";
267
+ ```
268
+
269
+ > Adapted from [PredictOS](https://github.com/PredictionXBT/PredictOS) by
270
+ > **PredictionXBT** (MIT licensed, © 2025). The original code shipped as
271
+ > Deno/Supabase edge functions; here it is refactored into plain, typed,
272
+ > dependency-light library functions with no HTTP/CORS layer. It lived in a
273
+ > sibling `predictos` package until that package was merged into `investing`.
274
+ > See [`NOTICE`](./NOTICE) and
275
+ > [`LICENSE-PredictOS-MIT`](./LICENSE-PredictOS-MIT).
276
+
277
+ #### What it covers
278
+
279
+ - **AI provider clients** — OpenAI (Responses API), Grok/xAI (Responses API,
280
+ with optional `x_search` / `web_search` tools), and BlockRun (x402
281
+ wallet-based micropayments across 20+ models), plus the analysis prompt
282
+ builders (`analyzeEventMarkets`, `bookmakerAnalysis`, `arbitrageAnalysis`,
283
+ `searchQueryGenerator`).
284
+ - **Market data clients** — Kalshi via the DFlow API
285
+ (`investing/predictos/data/kalshi`) and Polymarket via the Dome API
286
+ (`investing/predictos/data/polymarket`).
287
+ - **Multi-agent pipeline** (`investing/predictos/agents`):
288
+ - `runEventAnalysisAgent` — analyzes an event's markets for alpha and a
289
+ predicted winner.
290
+ - `runBookmakerAgent` — aggregates multiple agent analyses (and optional
291
+ external data sources) into a single consolidated assessment.
292
+ - `runMapperAgent` — turns an analysis into Polymarket order parameters
293
+ (pure logic; Kalshi mapping not yet implemented).
294
+ - **Cross-platform arbitrage** (`investing/predictos/arbitrage`) —
295
+ `findArbitrage` parses a Polymarket/Kalshi URL, generates a search query with
296
+ AI, searches the other platform, and evaluates whether the same event is
297
+ mispriced across venues.
298
+ - **Event fetching** (`getEvents`) — resolves a Polymarket/Kalshi/Jupiter URL
299
+ into its raw markets (Kalshi via DFlow, Polymarket via the Gamma API).
300
+
301
+ #### Subpath exports
302
+
303
+ | Import | Contents |
304
+ | --- | --- |
305
+ | `investing/predictos` | Everything (barrel) |
306
+ | `investing/predictos/ai` | AI clients + prompt builders |
307
+ | `investing/predictos/data/kalshi` | Kalshi (DFlow) data client |
308
+ | `investing/predictos/data/polymarket` | Polymarket (Dome) data client |
309
+ | `investing/predictos/agents` | `runEventAnalysisAgent`, `runBookmakerAgent`, `runMapperAgent` |
310
+ | `investing/predictos/arbitrage` | `findArbitrage` |
311
+
312
+ The barrel re-exports the Kalshi (DFlow) client at the top level. The Polymarket
313
+ (Dome) client exposes Kalshi helpers under the same names, so the barrel renames
314
+ those two to `getDomeKalshiMarketsByEvent` / `buildDomeKalshiMarketUrl` — import
315
+ from `investing/predictos/data/polymarket` for their original names. The
316
+ Gamma/CLOB trading client, Polyfactual and x402 are namespaced on the barrel as
317
+ `polymarketClob`, `polyfactual` and `x402` for the same reason.
318
+
319
+ #### Refactor notes (Deno → Node)
320
+
321
+ - Deno HTTP handlers (`Deno.serve`, `new Response(...)`, CORS headers) were
322
+ removed. Each endpoint is now a plain exported async function taking typed
323
+ parameters and returning a typed result; validation failures `throw`.
324
+ - `Deno.env.get("X")` was replaced with config/options objects
325
+ (`AIConfig`, `DataConfig`, per-call `apiKey`/`walletKey`) that fall back to
326
+ `process.env` (`OPENAI_API_KEY`, `XAI_API_KEY`, `BLOCKRUN_WALLET_KEY`,
327
+ `DOME_API_KEY`, `DFLOW_API_KEY`). No secrets are hardcoded.
328
+ - Remote (`https://...`) and `npm:` import specifiers were replaced with normal
329
+ package imports (`ethers`). The global `fetch` (Node 18+) is used throughout.
330
+ - Prompt text and analysis logic are preserved verbatim.
331
+
332
+ #### Not ported (yet)
333
+
334
+ Intentionally left out of the core port — noted for future work: the Next.js
335
+ `terminal/` frontend, the Python alpha-hunter examples, the **pay.sh** payment
336
+ serving flows, **Irys** verifiable-agent storage, wallet-tracking websockets, and
337
+ on-chain order execution (the mapper produces order parameters, but placing
338
+ orders is out of scope). The BlockRun client *is* ported (it only needs `ethers`
339
+ + `fetch`), but its on-chain micropayment flow is untested in this environment.
340
+
224
341
  ### Trading Agents
225
342
 
226
343
  ```typescript
@@ -300,6 +417,12 @@ ALPACA_SECRET=your_secret_here
300
417
  # OpenAI for AI-powered analysis
301
418
  OPENAI_API_KEY=your_openai_key
302
419
 
420
+ # PredictOS: prediction-market analysis and data
421
+ XAI_API_KEY=your_xai_key # Grok/xAI
422
+ BLOCKRUN_WALLET_KEY=your_wallet_key # BlockRun x402 micropayments
423
+ DOME_API_KEY=your_dome_key # Polymarket market data
424
+ DFLOW_API_KEY=your_dflow_key # Kalshi market data
425
+
303
426
  # Optional: Alternative LLM providers
304
427
  ANTHROPIC_API_KEY=your_anthropic_key
305
428
  GOOGLE_API_KEY=your_google_key
@@ -412,7 +535,15 @@ See the `/examples` directory for complete working examples:
412
535
 
413
536
  - [GitHub Repository](https://github.com/vtempest/ai-broker-investment-agent)
414
537
  - [Documentation](https://invest.vtempest.com/docs)
538
+ - [Agent skill](../../skills/ask-investing/SKILL.md)
415
539
  - [Examples](./examples)
416
540
 
541
+ ## Credits
542
+
543
+ The `predictos` module is a derivative work of
544
+ [PredictOS](https://github.com/PredictionXBT/PredictOS) — all original design and
545
+ logic © 2025 PredictionXBT, MIT licensed. See [`NOTICE`](./NOTICE) and
546
+ [`LICENSE-PredictOS-MIT`](./LICENSE-PredictOS-MIT).
547
+
417
548
  - [GitHub Issues](https://github.com/vtempest/ai-broker-investment-agent/issues)
418
549
  - [Documentation](https://invest.vtempest.com/docs)