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.
- package/LICENSE-PredictOS-MIT +22 -0
- package/NOTICE +10 -0
- package/README.md +131 -0
- package/dist/{archiver-web.es-EPYdovFt.js → archiver-web.es-B69gABHP.js} +1 -1
- package/dist/{archiver-web.es-BgXzilRH.cjs → archiver-web.es-fg4bLLZa.cjs} +1 -1
- package/dist/bookmakerAnalysis-Bfo1zUVm.js +1 -0
- package/dist/bookmakerAnalysis-CHn1W8uX.cjs +1 -0
- package/dist/callGrok-D0D7zBHK.js +1 -0
- package/dist/callGrok-DWO719mN.cjs +1 -0
- package/dist/events-BJOyGWeU.cjs +1 -0
- package/dist/events-OvBb8rgy.js +1 -0
- package/dist/{index-C9OpAHBe.js → index-D7fsk2gy.js} +2 -2
- package/dist/{index-CcyBsxYm.cjs → index-_V1Ql5Es.cjs} +2 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/polymarket-updown-15-limit-order-bot-DCC8HE9Z.cjs +1 -0
- package/dist/polymarket-updown-15-limit-order-bot-Dv5oGAF4.js +1 -0
- package/dist/predictos/agents/bookmaker-agent.d.ts +8 -0
- package/dist/predictos/agents/bookmaker-agent.d.ts.map +1 -0
- package/dist/predictos/agents/event-analysis-agent.d.ts +8 -0
- package/dist/predictos/agents/event-analysis-agent.d.ts.map +1 -0
- package/dist/predictos/agents/index.d.ts +21 -0
- package/dist/predictos/agents/index.d.ts.map +1 -0
- package/dist/predictos/agents/index.js +1 -0
- package/dist/predictos/agents/index.mjs +1 -0
- package/dist/predictos/agents/mapper-agent.d.ts +17 -0
- package/dist/predictos/agents/mapper-agent.d.ts.map +1 -0
- package/dist/predictos/agents/polyfactual-research.d.ts +47 -0
- package/dist/predictos/agents/polyfactual-research.d.ts.map +1 -0
- package/dist/predictos/agents/polymarket-position-tracker.d.ts +31 -0
- package/dist/predictos/agents/polymarket-position-tracker.d.ts.map +1 -0
- package/dist/predictos/agents/polymarket-put-order.d.ts +88 -0
- package/dist/predictos/agents/polymarket-put-order.d.ts.map +1 -0
- package/dist/predictos/agents/polymarket-updown-15-limit-order-bot.d.ts +92 -0
- package/dist/predictos/agents/polymarket-updown-15-limit-order-bot.d.ts.map +1 -0
- package/dist/predictos/agents/x402-seller.d.ts +34 -0
- package/dist/predictos/agents/x402-seller.d.ts.map +1 -0
- package/dist/predictos/ai/callBlockRun.d.ts +54 -0
- package/dist/predictos/ai/callBlockRun.d.ts.map +1 -0
- package/dist/predictos/ai/callGrok.d.ts +22 -0
- package/dist/predictos/ai/callGrok.d.ts.map +1 -0
- package/dist/predictos/ai/callOpenAI.d.ts +19 -0
- package/dist/predictos/ai/callOpenAI.d.ts.map +1 -0
- package/dist/predictos/ai/http.d.ts +19 -0
- package/dist/predictos/ai/http.d.ts.map +1 -0
- package/dist/predictos/ai/index.d.ts +19 -0
- package/dist/predictos/ai/index.d.ts.map +1 -0
- package/dist/predictos/ai/index.js +1 -0
- package/dist/predictos/ai/index.mjs +1 -0
- package/dist/predictos/ai/prompts/analyzeEventMarkets.d.ts +12 -0
- package/dist/predictos/ai/prompts/analyzeEventMarkets.d.ts.map +1 -0
- package/dist/predictos/ai/prompts/arbitrageAnalysis.d.ts +14 -0
- package/dist/predictos/ai/prompts/arbitrageAnalysis.d.ts.map +1 -0
- package/dist/predictos/ai/prompts/bookmakerAnalysis.d.ts +17 -0
- package/dist/predictos/ai/prompts/bookmakerAnalysis.d.ts.map +1 -0
- package/dist/predictos/ai/prompts/searchQueryGenerator.d.ts +18 -0
- package/dist/predictos/ai/prompts/searchQueryGenerator.d.ts.map +1 -0
- package/dist/predictos/ai/types.d.ts +214 -0
- package/dist/predictos/ai/types.d.ts.map +1 -0
- package/dist/predictos/arbitrage.d.ts +8 -0
- package/dist/predictos/arbitrage.d.ts.map +1 -0
- package/dist/predictos/arbitrage.js +1 -0
- package/dist/predictos/arbitrage.mjs +1 -0
- package/dist/predictos/clients/polyfactual.d.ts +72 -0
- package/dist/predictos/clients/polyfactual.d.ts.map +1 -0
- package/dist/predictos/clients/polymarket.d.ts +283 -0
- package/dist/predictos/clients/polymarket.d.ts.map +1 -0
- package/dist/predictos/clients/x402.d.ts +213 -0
- package/dist/predictos/clients/x402.d.ts.map +1 -0
- package/dist/predictos/data/kalshi.d.ts +66 -0
- package/dist/predictos/data/kalshi.d.ts.map +1 -0
- package/dist/predictos/data/kalshi.js +1 -0
- package/dist/predictos/data/kalshi.mjs +1 -0
- package/dist/predictos/data/polymarket.d.ts +105 -0
- package/dist/predictos/data/polymarket.d.ts.map +1 -0
- package/dist/predictos/data/polymarket.js +1 -0
- package/dist/predictos/data/polymarket.mjs +1 -0
- package/dist/predictos/events.d.ts +9 -0
- package/dist/predictos/events.d.ts.map +1 -0
- package/dist/predictos/index.d.ts +22 -7
- package/dist/predictos/index.d.ts.map +1 -1
- package/dist/predictos/index.js +1 -0
- package/dist/predictos/index.mjs +1 -0
- package/dist/predictos/types.d.ts +408 -0
- package/dist/predictos/types.d.ts.map +1 -0
- package/dist/searchQueryGenerator-DIIs9xw5.js +1 -0
- package/dist/searchQueryGenerator-rCVblXJS.cjs +1 -0
- 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)
|