@spfunctions/cli 1.2.1 → 1.4.0
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/commands/agent.js +365 -0
- package/dist/commands/dashboard.js +3 -14
- package/dist/commands/liquidity.d.ts +12 -0
- package/dist/commands/liquidity.js +293 -0
- package/dist/commands/performance.d.ts +8 -0
- package/dist/commands/performance.js +261 -0
- package/dist/commands/setup.js +123 -123
- package/dist/index.js +26 -3
- package/dist/kalshi.d.ts +18 -0
- package/dist/kalshi.js +43 -0
- package/dist/topics.d.ts +14 -0
- package/dist/topics.js +44 -0
- package/package.json +2 -2
package/dist/kalshi.d.ts
CHANGED
|
@@ -58,6 +58,15 @@ export interface LocalOrderbook {
|
|
|
58
58
|
liquidityScore: 'high' | 'medium' | 'low';
|
|
59
59
|
}
|
|
60
60
|
export declare function getOrderbook(ticker: string): Promise<LocalOrderbook | null>;
|
|
61
|
+
export interface PublicOrderbook {
|
|
62
|
+
yes_dollars: Array<[string, string]>;
|
|
63
|
+
no_dollars: Array<[string, string]>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Fetch orderbook for a ticker using the public (unauthenticated) endpoint.
|
|
67
|
+
* Returns raw yes_dollars/no_dollars arrays or null on failure.
|
|
68
|
+
*/
|
|
69
|
+
export declare function getPublicOrderbook(ticker: string, depth?: number): Promise<PublicOrderbook | null>;
|
|
61
70
|
export declare function getSettlements(params?: {
|
|
62
71
|
limit?: number;
|
|
63
72
|
cursor?: string;
|
|
@@ -116,6 +125,15 @@ export declare function amendOrder(orderId: string, params: {
|
|
|
116
125
|
}): Promise<{
|
|
117
126
|
order: any;
|
|
118
127
|
}>;
|
|
128
|
+
export declare function getBatchCandlesticks(params: {
|
|
129
|
+
tickers: string[];
|
|
130
|
+
startTs: number;
|
|
131
|
+
endTs: number;
|
|
132
|
+
periodInterval?: number;
|
|
133
|
+
}): Promise<{
|
|
134
|
+
market_ticker: string;
|
|
135
|
+
candlesticks: any[];
|
|
136
|
+
}[]>;
|
|
119
137
|
export declare function createRFQ(params: {
|
|
120
138
|
market_ticker: string;
|
|
121
139
|
contracts: number;
|
package/dist/kalshi.js
CHANGED
|
@@ -19,6 +19,7 @@ exports.getPositions = getPositions;
|
|
|
19
19
|
exports.kalshiPriceCents = kalshiPriceCents;
|
|
20
20
|
exports.getMarketPrice = getMarketPrice;
|
|
21
21
|
exports.getOrderbook = getOrderbook;
|
|
22
|
+
exports.getPublicOrderbook = getPublicOrderbook;
|
|
22
23
|
exports.getSettlements = getSettlements;
|
|
23
24
|
exports.getBalance = getBalance;
|
|
24
25
|
exports.getOrders = getOrders;
|
|
@@ -30,6 +31,7 @@ exports.createOrder = createOrder;
|
|
|
30
31
|
exports.cancelOrder = cancelOrder;
|
|
31
32
|
exports.batchCancelOrders = batchCancelOrders;
|
|
32
33
|
exports.amendOrder = amendOrder;
|
|
34
|
+
exports.getBatchCandlesticks = getBatchCandlesticks;
|
|
33
35
|
exports.createRFQ = createRFQ;
|
|
34
36
|
const fs_1 = __importDefault(require("fs"));
|
|
35
37
|
const path_1 = __importDefault(require("path"));
|
|
@@ -278,6 +280,27 @@ async function getOrderbook(ticker) {
|
|
|
278
280
|
return null;
|
|
279
281
|
}
|
|
280
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Fetch orderbook for a ticker using the public (unauthenticated) endpoint.
|
|
285
|
+
* Returns raw yes_dollars/no_dollars arrays or null on failure.
|
|
286
|
+
*/
|
|
287
|
+
async function getPublicOrderbook(ticker, depth = 20) {
|
|
288
|
+
try {
|
|
289
|
+
const url = `${KALSHI_API_BASE}/markets/${ticker}/orderbook?depth=${depth}`;
|
|
290
|
+
const res = await fetch(url, { headers: { 'Accept': 'application/json' } });
|
|
291
|
+
if (!res.ok)
|
|
292
|
+
return null;
|
|
293
|
+
const data = await res.json();
|
|
294
|
+
const ob = data.orderbook_fp || data.orderbook || data;
|
|
295
|
+
return {
|
|
296
|
+
yes_dollars: ob.yes_dollars || ob.yes || [],
|
|
297
|
+
no_dollars: ob.no_dollars || ob.no || [],
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
281
304
|
// ============================================================================
|
|
282
305
|
// SETTLEMENTS (Authenticated)
|
|
283
306
|
// ============================================================================
|
|
@@ -450,6 +473,26 @@ async function amendOrder(orderId, params) {
|
|
|
450
473
|
}
|
|
451
474
|
return res.json();
|
|
452
475
|
}
|
|
476
|
+
// ============================================================================
|
|
477
|
+
// CANDLESTICKS (Authenticated)
|
|
478
|
+
// ============================================================================
|
|
479
|
+
async function getBatchCandlesticks(params) {
|
|
480
|
+
if (!isKalshiConfigured())
|
|
481
|
+
return [];
|
|
482
|
+
try {
|
|
483
|
+
const searchParams = new URLSearchParams();
|
|
484
|
+
searchParams.set('tickers', params.tickers.join(','));
|
|
485
|
+
searchParams.set('start_ts', params.startTs.toString());
|
|
486
|
+
searchParams.set('end_ts', params.endTs.toString());
|
|
487
|
+
searchParams.set('period_interval', (params.periodInterval ?? 1440).toString());
|
|
488
|
+
const data = await kalshiAuthGet(`/markets/candlesticks?${searchParams.toString()}`);
|
|
489
|
+
return data.candlesticks || [];
|
|
490
|
+
}
|
|
491
|
+
catch (err) {
|
|
492
|
+
console.warn('[Kalshi] Failed to fetch candlesticks:', err);
|
|
493
|
+
return [];
|
|
494
|
+
}
|
|
495
|
+
}
|
|
453
496
|
async function createRFQ(params) {
|
|
454
497
|
return kalshiAuthPost('/communications/rfqs', params);
|
|
455
498
|
}
|
package/dist/topics.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Topic → Kalshi series mapping
|
|
3
|
+
*
|
|
4
|
+
* Shared between dashboard, liquidity scanner, and other commands
|
|
5
|
+
* that need to categorize markets by topic.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TOPIC_SERIES: Record<string, string[]>;
|
|
8
|
+
/** Map a series prefix to a human-readable category name (for dashboard display) */
|
|
9
|
+
export declare const RISK_CATEGORIES: Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Given a ticker string, return the topic name (uppercased).
|
|
12
|
+
* Matches longest prefix first to avoid ambiguity (e.g. KXWTIMAX before KXWTI).
|
|
13
|
+
*/
|
|
14
|
+
export declare function tickerToTopic(ticker: string): string;
|
package/dist/topics.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Topic → Kalshi series mapping
|
|
4
|
+
*
|
|
5
|
+
* Shared between dashboard, liquidity scanner, and other commands
|
|
6
|
+
* that need to categorize markets by topic.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RISK_CATEGORIES = exports.TOPIC_SERIES = void 0;
|
|
10
|
+
exports.tickerToTopic = tickerToTopic;
|
|
11
|
+
exports.TOPIC_SERIES = {
|
|
12
|
+
oil: ['KXWTIMAX', 'KXWTIW', 'KXWTID'],
|
|
13
|
+
recession: ['KXRECSSNBER'],
|
|
14
|
+
fed: ['KXFEDDECISION'],
|
|
15
|
+
cpi: ['KXCPI'],
|
|
16
|
+
gas: ['KXAAAGASM'],
|
|
17
|
+
sp500: ['KXINXY'],
|
|
18
|
+
};
|
|
19
|
+
/** Map a series prefix to a human-readable category name (for dashboard display) */
|
|
20
|
+
exports.RISK_CATEGORIES = {
|
|
21
|
+
KXWTIMAX: 'Oil',
|
|
22
|
+
KXWTI: 'Oil',
|
|
23
|
+
KXRECSSNBER: 'Recession',
|
|
24
|
+
KXAAAGASM: 'Gas',
|
|
25
|
+
KXCPI: 'Inflation',
|
|
26
|
+
KXINXY: 'S&P 500',
|
|
27
|
+
KXFEDDECISION: 'Fed Rate',
|
|
28
|
+
KXUNEMPLOYMENT: 'Unemployment',
|
|
29
|
+
KXCLOSEHORMUZ: 'Hormuz',
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Given a ticker string, return the topic name (uppercased).
|
|
33
|
+
* Matches longest prefix first to avoid ambiguity (e.g. KXWTIMAX before KXWTI).
|
|
34
|
+
*/
|
|
35
|
+
function tickerToTopic(ticker) {
|
|
36
|
+
const sorted = Object.entries(exports.TOPIC_SERIES)
|
|
37
|
+
.flatMap(([topic, series]) => series.map(s => ({ prefix: s, topic })))
|
|
38
|
+
.sort((a, b) => b.prefix.length - a.prefix.length);
|
|
39
|
+
for (const { prefix, topic } of sorted) {
|
|
40
|
+
if (ticker.toUpperCase().startsWith(prefix))
|
|
41
|
+
return topic.toUpperCase();
|
|
42
|
+
}
|
|
43
|
+
return 'OTHER';
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spfunctions/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
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"
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
42
|
-
"url": "https://github.com/
|
|
42
|
+
"url": "https://github.com/spfunctions/simplefunctions-cli"
|
|
43
43
|
}
|
|
44
44
|
}
|