@spfunctions/cli 1.7.1 → 1.7.2
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/dist/client.d.ts +1 -0
- package/dist/client.js +5 -0
- package/dist/commands/context.js +10 -9
- package/dist/commands/query.js +10 -3
- package/dist/commands/trade.js +24 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -35,3 +35,4 @@ export declare function kalshiFetchMarketsBySeries(seriesTicker: string): Promis
|
|
|
35
35
|
export declare function kalshiFetchMarketsByEvent(eventTicker: string): Promise<any[]>;
|
|
36
36
|
export declare function fetchGlobalContext(): Promise<any>;
|
|
37
37
|
export declare function fetchQuery(q: string): Promise<any>;
|
|
38
|
+
export declare function fetchTraditionalMarkets(): Promise<any>;
|
package/dist/client.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.kalshiFetchMarketsBySeries = kalshiFetchMarketsBySeries;
|
|
|
14
14
|
exports.kalshiFetchMarketsByEvent = kalshiFetchMarketsByEvent;
|
|
15
15
|
exports.fetchGlobalContext = fetchGlobalContext;
|
|
16
16
|
exports.fetchQuery = fetchQuery;
|
|
17
|
+
exports.fetchTraditionalMarkets = fetchTraditionalMarkets;
|
|
17
18
|
const DEFAULT_API_URL = 'https://simplefunctions.dev';
|
|
18
19
|
const KALSHI_BASE = 'https://api.elections.kalshi.com/trade-api/v2';
|
|
19
20
|
// ===== SF API Client =====
|
|
@@ -170,3 +171,7 @@ async function fetchQuery(q) {
|
|
|
170
171
|
throw new Error(`Query API error: ${res.status}`);
|
|
171
172
|
return res.json();
|
|
172
173
|
}
|
|
174
|
+
async function fetchTraditionalMarkets() {
|
|
175
|
+
const ctx = await fetchGlobalContext();
|
|
176
|
+
return ctx.traditionalMarkets || [];
|
|
177
|
+
}
|
package/dist/commands/context.js
CHANGED
|
@@ -18,9 +18,18 @@ async function contextCommand(id, opts) {
|
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
console.log(`\n${utils_js_1.c.bold}Market Snapshot${utils_js_1.c.reset} ${(0, utils_js_1.shortDate)(data.snapshotAt)}\n`);
|
|
21
|
+
if (data.edges?.length > 0) {
|
|
22
|
+
console.log(`${utils_js_1.c.bold}Thesis Edges${utils_js_1.c.reset}`);
|
|
23
|
+
for (const m of data.edges.slice(0, 10)) {
|
|
24
|
+
const venue = m.venue === 'kalshi' ? `${utils_js_1.c.cyan}K${utils_js_1.c.reset}` : `${utils_js_1.c.magenta}P${utils_js_1.c.reset}`;
|
|
25
|
+
const edgeStr = m.edge > 0 ? `${utils_js_1.c.green}+${m.edge}¢${utils_js_1.c.reset}` : `${utils_js_1.c.red}${m.edge}¢${utils_js_1.c.reset}`;
|
|
26
|
+
console.log(` ${venue} ${String(m.price).padStart(3)}¢ edge ${edgeStr.padStart(14)} ${m.title.slice(0, 50)}`);
|
|
27
|
+
}
|
|
28
|
+
console.log();
|
|
29
|
+
}
|
|
21
30
|
if (data.movers?.length > 0) {
|
|
22
31
|
console.log(`${utils_js_1.c.bold}Movers (24h)${utils_js_1.c.reset}`);
|
|
23
|
-
for (const m of data.movers.slice(0,
|
|
32
|
+
for (const m of data.movers.slice(0, 8)) {
|
|
24
33
|
const venue = m.venue === 'kalshi' ? `${utils_js_1.c.cyan}K${utils_js_1.c.reset}` : `${utils_js_1.c.magenta}P${utils_js_1.c.reset}`;
|
|
25
34
|
const ch = m.change24h > 0 ? `${utils_js_1.c.green}+${m.change24h}¢${utils_js_1.c.reset}` : `${utils_js_1.c.red}${m.change24h}¢${utils_js_1.c.reset}`;
|
|
26
35
|
console.log(` ${venue} ${String(m.price).padStart(3)}¢ ${ch.padStart(16)} ${m.title.slice(0, 55)}`);
|
|
@@ -34,14 +43,6 @@ async function contextCommand(id, opts) {
|
|
|
34
43
|
}
|
|
35
44
|
console.log();
|
|
36
45
|
}
|
|
37
|
-
if (data.expiring?.length > 0) {
|
|
38
|
-
console.log(`${utils_js_1.c.bold}Expiring (7d)${utils_js_1.c.reset}`);
|
|
39
|
-
for (const m of data.expiring.slice(0, 8)) {
|
|
40
|
-
const venue = m.venue === 'kalshi' ? `${utils_js_1.c.cyan}K${utils_js_1.c.reset}` : `${utils_js_1.c.magenta}P${utils_js_1.c.reset}`;
|
|
41
|
-
console.log(` ${venue} ${String(m.price).padStart(3)}¢ ${utils_js_1.c.dim}${String(m.hoursUntil).padStart(3)}h${utils_js_1.c.reset} ${m.title.slice(0, 55)}`);
|
|
42
|
-
}
|
|
43
|
-
console.log();
|
|
44
|
-
}
|
|
45
46
|
if (data.liquid?.length > 0) {
|
|
46
47
|
console.log(`${utils_js_1.c.bold}Liquid${utils_js_1.c.reset}`);
|
|
47
48
|
for (const m of data.liquid.slice(0, 8)) {
|
package/dist/commands/query.js
CHANGED
|
@@ -62,11 +62,18 @@ async function queryCommand(q, opts) {
|
|
|
62
62
|
}
|
|
63
63
|
console.log();
|
|
64
64
|
}
|
|
65
|
-
//
|
|
66
|
-
if (data.
|
|
65
|
+
// Theses
|
|
66
|
+
if (data.theses?.length > 0) {
|
|
67
|
+
console.log(` \x1b[1mTheses\x1b[22m`);
|
|
68
|
+
for (const t of data.theses.slice(0, 3)) {
|
|
69
|
+
console.log(` ${t.confidence || '?'}% ${String(t.edges || 0).padStart(2)} edges ${t.title.slice(0, 50)}`);
|
|
70
|
+
}
|
|
71
|
+
console.log();
|
|
72
|
+
}
|
|
73
|
+
else if (data.thesis) {
|
|
74
|
+
// Backward compat
|
|
67
75
|
const t = data.thesis;
|
|
68
76
|
console.log(` \x1b[1mThesis\x1b[22m`);
|
|
69
|
-
console.log(` ${t.title.slice(0, 60)}`);
|
|
70
77
|
console.log(` ${t.confidence}% confidence ${t.edges} edges /thesis/${t.slug}`);
|
|
71
78
|
console.log();
|
|
72
79
|
}
|
package/dist/commands/trade.js
CHANGED
|
@@ -5,6 +5,9 @@ exports.sellCommand = sellCommand;
|
|
|
5
5
|
const kalshi_js_1 = require("../kalshi.js");
|
|
6
6
|
const config_js_1 = require("../config.js");
|
|
7
7
|
const utils_js_1 = require("../utils.js");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const os_1 = require("os");
|
|
8
11
|
async function buyCommand(ticker, qty, opts) {
|
|
9
12
|
(0, config_js_1.requireTrading)();
|
|
10
13
|
await executeOrder(ticker, qty, 'buy', opts);
|
|
@@ -62,6 +65,27 @@ async function executeOrder(ticker, qty, action, opts) {
|
|
|
62
65
|
if (order.fill_count_fp)
|
|
63
66
|
console.log(` Filled: ${order.fill_count_fp}/${order.initial_count_fp || quantity}`);
|
|
64
67
|
console.log();
|
|
68
|
+
// Auto-log trade to journal
|
|
69
|
+
try {
|
|
70
|
+
const journalDir = (0, path_1.join)((0, os_1.homedir)(), '.sf');
|
|
71
|
+
if (!(0, fs_1.existsSync)(journalDir))
|
|
72
|
+
(0, fs_1.mkdirSync)(journalDir, { recursive: true });
|
|
73
|
+
const entry = JSON.stringify({
|
|
74
|
+
ts: new Date().toISOString(),
|
|
75
|
+
action,
|
|
76
|
+
ticker,
|
|
77
|
+
side,
|
|
78
|
+
quantity,
|
|
79
|
+
price: priceCents || null,
|
|
80
|
+
type: orderType,
|
|
81
|
+
orderId: order.order_id || null,
|
|
82
|
+
status: order.status || null,
|
|
83
|
+
filled: order.fill_count_fp || null,
|
|
84
|
+
}) + '\n';
|
|
85
|
+
(0, fs_1.appendFileSync)((0, path_1.join)(journalDir, 'trade-journal.jsonl'), entry);
|
|
86
|
+
console.log(` ${utils_js_1.c.dim}Trade logged to ~/.sf/trade-journal.jsonl${utils_js_1.c.reset}`);
|
|
87
|
+
}
|
|
88
|
+
catch { /* journal logging is best-effort */ }
|
|
65
89
|
}
|
|
66
90
|
catch (err) {
|
|
67
91
|
const msg = err.message || String(err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spfunctions/cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Prediction market intelligence CLI. Causal thesis model, 24/7 Kalshi/Polymarket scan, live orderbook, edge detection. Interactive agent mode with tool calling.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sf": "./dist/index.js"
|