skewtape 0.0.1 → 0.1.4

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 (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +182 -0
  3. package/dist/cjs/backtest.d.ts +146 -0
  4. package/dist/cjs/backtest.js +410 -0
  5. package/dist/cjs/client.d.ts +255 -0
  6. package/dist/cjs/client.js +447 -0
  7. package/dist/cjs/download.d.ts +33 -0
  8. package/dist/cjs/download.js +160 -0
  9. package/dist/cjs/errors.d.ts +76 -0
  10. package/dist/cjs/errors.js +159 -0
  11. package/dist/cjs/exact.d.ts +36 -0
  12. package/dist/cjs/exact.js +168 -0
  13. package/dist/cjs/fees.d.ts +68 -0
  14. package/dist/cjs/fees.js +196 -0
  15. package/dist/cjs/geoblock.d.ts +48 -0
  16. package/dist/cjs/geoblock.js +78 -0
  17. package/dist/cjs/index.d.ts +31 -0
  18. package/dist/cjs/index.js +98 -0
  19. package/dist/cjs/kalshi.d.ts +261 -0
  20. package/dist/cjs/kalshi.js +416 -0
  21. package/dist/cjs/keccak.d.ts +10 -0
  22. package/dist/cjs/keccak.js +84 -0
  23. package/dist/cjs/msgpack.d.ts +15 -0
  24. package/dist/cjs/msgpack.js +112 -0
  25. package/dist/cjs/package.json +1 -0
  26. package/dist/cjs/paginated.d.ts +26 -0
  27. package/dist/cjs/paginated.js +51 -0
  28. package/dist/cjs/quote-math.d.ts +146 -0
  29. package/dist/cjs/quote-math.js +446 -0
  30. package/dist/cjs/quote.d.ts +108 -0
  31. package/dist/cjs/quote.js +307 -0
  32. package/dist/cjs/route-hyperliquid.d.ts +228 -0
  33. package/dist/cjs/route-hyperliquid.js +387 -0
  34. package/dist/cjs/route.d.ts +297 -0
  35. package/dist/cjs/route.js +516 -0
  36. package/dist/cjs/stream.d.ts +99 -0
  37. package/dist/cjs/stream.js +529 -0
  38. package/dist/cjs/version.d.ts +6 -0
  39. package/dist/cjs/version.js +9 -0
  40. package/dist/esm/backtest.d.ts +146 -0
  41. package/dist/esm/backtest.js +403 -0
  42. package/dist/esm/client.d.ts +255 -0
  43. package/dist/esm/client.js +441 -0
  44. package/dist/esm/download.d.ts +33 -0
  45. package/dist/esm/download.js +155 -0
  46. package/dist/esm/errors.d.ts +76 -0
  47. package/dist/esm/errors.js +142 -0
  48. package/dist/esm/exact.d.ts +36 -0
  49. package/dist/esm/exact.js +158 -0
  50. package/dist/esm/fees.d.ts +68 -0
  51. package/dist/esm/fees.js +185 -0
  52. package/dist/esm/geoblock.d.ts +48 -0
  53. package/dist/esm/geoblock.js +74 -0
  54. package/dist/esm/index.d.ts +31 -0
  55. package/dist/esm/index.js +30 -0
  56. package/dist/esm/kalshi.d.ts +261 -0
  57. package/dist/esm/kalshi.js +404 -0
  58. package/dist/esm/keccak.d.ts +10 -0
  59. package/dist/esm/keccak.js +80 -0
  60. package/dist/esm/msgpack.d.ts +15 -0
  61. package/dist/esm/msgpack.js +109 -0
  62. package/dist/esm/paginated.d.ts +26 -0
  63. package/dist/esm/paginated.js +47 -0
  64. package/dist/esm/quote-math.d.ts +146 -0
  65. package/dist/esm/quote-math.js +437 -0
  66. package/dist/esm/quote.d.ts +108 -0
  67. package/dist/esm/quote.js +297 -0
  68. package/dist/esm/route-hyperliquid.d.ts +228 -0
  69. package/dist/esm/route-hyperliquid.js +376 -0
  70. package/dist/esm/route.d.ts +297 -0
  71. package/dist/esm/route.js +507 -0
  72. package/dist/esm/stream.d.ts +99 -0
  73. package/dist/esm/stream.js +524 -0
  74. package/dist/esm/version.d.ts +6 -0
  75. package/dist/esm/version.js +6 -0
  76. package/package.json +48 -1
  77. package/src/backtest.ts +490 -0
  78. package/src/client.ts +595 -0
  79. package/src/download.ts +161 -0
  80. package/src/errors.ts +143 -0
  81. package/src/exact.ts +159 -0
  82. package/src/fees.ts +189 -0
  83. package/src/generated/schema.d.ts +2500 -0
  84. package/src/geoblock.ts +90 -0
  85. package/src/index.ts +146 -0
  86. package/src/kalshi.ts +563 -0
  87. package/src/keccak.ts +82 -0
  88. package/src/msgpack.ts +83 -0
  89. package/src/paginated.ts +51 -0
  90. package/src/quote-math.ts +555 -0
  91. package/src/quote.ts +324 -0
  92. package/src/route-hyperliquid.ts +457 -0
  93. package/src/route.ts +631 -0
  94. package/src/stream.ts +539 -0
  95. package/src/version.ts +6 -0
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ /**
3
+ * Fees from the schedule: the row in force for a fill and the fee it gives,
4
+ * exactly as Skewtape computes them (tape's internal/fees,
5
+ * docs.skewtape.com/fees). The fee is kept as an exact fraction until it is
6
+ * rounded, as the row says, to a step given in millionths of a dollar; a
7
+ * minimum, when the row has one, raises a fee that is above zero after
8
+ * rounding. conformance/fees.json pins every case, and the tests run all of it.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.FeeError = exports.FALLBACK_CATEGORY = exports.COLLATERAL_MICROS_DECIMALS = void 0;
12
+ exports.feeRowOf = feeRowOf;
13
+ exports.microsToRaw = microsToRaw;
14
+ exports.exactFee = exactFee;
15
+ exports.takerFeeRaw = takerFeeRaw;
16
+ exports.takerFeeOf = takerFeeOf;
17
+ exports.makerFeeRaw = makerFeeRaw;
18
+ exports.selectFeeRow = selectFeeRow;
19
+ const errors_js_1 = require("./errors.js");
20
+ const exact_js_1 = require("./exact.js");
21
+ exports.COLLATERAL_MICROS_DECIMALS = 6;
22
+ exports.FALLBACK_CATEGORY = "*";
23
+ const MICROS_PER_UNIT = 1000000n;
24
+ /** A fee that cannot be computed: an unknown formula or rounding, a missing parameter, a size out of range. */
25
+ class FeeError extends errors_js_1.SkewtapeError {
26
+ }
27
+ exports.FeeError = FeeError;
28
+ function intMap(v) {
29
+ if (v === null || v === undefined)
30
+ return {};
31
+ if (typeof v !== "object")
32
+ throw new FeeError(`${String(v)} is not a parameter map`);
33
+ const out = {};
34
+ for (const [k, x] of Object.entries(v))
35
+ out[k] = (0, exact_js_1.parseInt64)(x, k);
36
+ return out;
37
+ }
38
+ /** A FeeRow from the API's Fee, its JSON, or a FeeRow. */
39
+ function feeRowOf(row) {
40
+ if ("effectiveFrom" in row && typeof row.effectiveFrom === "bigint")
41
+ return row;
42
+ const r = row;
43
+ if (r.effective_from === undefined || r.effective_from === null)
44
+ throw new FeeError("a fee row needs effective_from");
45
+ const min = r.min_fee_micros;
46
+ return {
47
+ venue: String(r.venue),
48
+ category: String(r.category),
49
+ effectiveFrom: (0, exact_js_1.parseMicros)(r.effective_from, "effective_from"),
50
+ effectiveTo: r.effective_to === null || r.effective_to === undefined || r.effective_to === "" ? null : (0, exact_js_1.parseMicros)(r.effective_to, "effective_to"),
51
+ formula: String(r.formula),
52
+ rounding: String(r.rounding),
53
+ takerParams: intMap(r.taker_params),
54
+ makerRebateParams: intMap(r.maker_rebate_params),
55
+ minFeeMicros: min === null || min === undefined || min === "" ? null : (0, exact_js_1.parseInt64)(min, "min_fee_micros"),
56
+ };
57
+ }
58
+ /** A millionth-of-a-dollar amount in raw units at decimals. */
59
+ function microsToRaw(micros, decimals) {
60
+ if (decimals < 0 || decimals > 18 || !Number.isInteger(decimals))
61
+ throw new FeeError(`decimals ${decimals} out of range`);
62
+ if (decimals >= exports.COLLATERAL_MICROS_DECIMALS)
63
+ return micros * 10n ** BigInt(decimals - exports.COLLATERAL_MICROS_DECIMALS);
64
+ const factor = 10n ** BigInt(exports.COLLATERAL_MICROS_DECIMALS - decimals);
65
+ if (micros % factor !== 0n)
66
+ throw new FeeError(`${micros} micros is not representable at ${decimals} decimals`);
67
+ return micros / factor;
68
+ }
69
+ /**
70
+ * A fee formula's value for size shares against notional collateral (any one
71
+ * unit for both), exact, before rounding and any minimum: the one port of
72
+ * tape's internal/fees formulas, which takerFeeRaw and sk.quote both use.
73
+ */
74
+ function exactFee(formula, params, size, notional) {
75
+ switch (formula) {
76
+ case "quadratic": {
77
+ const rate = params.rate_micros;
78
+ if (rate === undefined)
79
+ throw new FeeError("quadratic needs rate_micros");
80
+ if (rate < 0n)
81
+ throw new FeeError("rate_micros must be >= 0");
82
+ if (rate === 0n || notional === 0n || notional === size)
83
+ return new exact_js_1.Rat(0n);
84
+ return new exact_js_1.Rat(rate * notional * (size - notional), size * MICROS_PER_UNIT);
85
+ }
86
+ case "complement": {
87
+ const rate = params.rate_micros;
88
+ if (rate === undefined)
89
+ throw new FeeError("complement needs rate_micros");
90
+ if (rate < 0n)
91
+ throw new FeeError("rate_micros must be >= 0");
92
+ return new exact_js_1.Rat(rate * (size - notional), MICROS_PER_UNIT);
93
+ }
94
+ case "flat_bps": {
95
+ const bps = params.bps;
96
+ if (bps === undefined)
97
+ throw new FeeError("flat_bps needs bps");
98
+ if (bps < 0n)
99
+ throw new FeeError("bps must be >= 0");
100
+ return new exact_js_1.Rat(notional * bps, 10000n);
101
+ }
102
+ case "zero":
103
+ return new exact_js_1.Rat(0n);
104
+ default:
105
+ throw new FeeError(`unknown formula ${formula}`);
106
+ }
107
+ }
108
+ function roundFee(exact, mode, step) {
109
+ if (exact.n < 0n)
110
+ throw new FeeError("negative fee");
111
+ if (step <= 0n)
112
+ step = 1n;
113
+ if (mode === "none") {
114
+ if (!exact.isInt())
115
+ throw new FeeError("rounding none needs an integer fee");
116
+ return exact.n;
117
+ }
118
+ if (mode !== "down" && mode !== "up" && mode !== "nearest")
119
+ throw new FeeError(`unknown rounding ${mode}`);
120
+ const den = exact.d * step;
121
+ let q = exact.n / den;
122
+ const r = exact.n % den;
123
+ if (mode === "up" && r !== 0n)
124
+ q += 1n;
125
+ else if (mode === "nearest" && 2n * r >= den)
126
+ q += 1n;
127
+ return q * step;
128
+ }
129
+ /**
130
+ * The taker fee in raw units for sizeRaw shares against notionalRaw
131
+ * collateral, both at decimals, under row: the formula exactly, rounded to
132
+ * round_step_micros (1 raw unit without one), then raised to min_fee_micros
133
+ * when it is above zero and below it.
134
+ */
135
+ function takerFeeRaw(row, sizeRaw, notionalRaw, decimals) {
136
+ return takerFeeOf(feeRowOf(row), sizeRaw, notionalRaw, decimals);
137
+ }
138
+ /**
139
+ * takerFeeRaw over a fee's terms alone, for callers that hold no whole row:
140
+ * sk.quote computes its fees with it at 6 decimals.
141
+ */
142
+ function takerFeeOf(fee, sizeRaw, notionalRaw, decimals) {
143
+ if (sizeRaw <= 0n)
144
+ throw new FeeError("size_raw must be positive");
145
+ if (notionalRaw < 0n || notionalRaw > sizeRaw)
146
+ throw new FeeError("notional_raw must be between 0 and size_raw");
147
+ const exact = exactFee(fee.formula, fee.takerParams, sizeRaw, notionalRaw);
148
+ const stepMicros = fee.takerParams.round_step_micros ?? 0n;
149
+ let rounded = roundFee(exact, fee.rounding, stepMicros > 0n ? microsToRaw(stepMicros, decimals) : 1n);
150
+ if (fee.minFeeMicros !== null && rounded > 0n) {
151
+ const min = microsToRaw(fee.minFeeMicros, decimals);
152
+ if (rounded < min)
153
+ rounded = min;
154
+ }
155
+ return rounded;
156
+ }
157
+ /**
158
+ * The maker's fee on venues that charge makers (maker_fee_rate_micros in
159
+ * maker_rebate_params, quadratic, with the row's rounding and step); zero
160
+ * elsewhere. A rebate share is data about the venue, not a fee, and is not
161
+ * applied.
162
+ */
163
+ function makerFeeRaw(row, sizeRaw, notionalRaw, decimals) {
164
+ const r = feeRowOf(row);
165
+ const rate = r.makerRebateParams.maker_fee_rate_micros ?? 0n;
166
+ if (rate === 0n)
167
+ return 0n;
168
+ const params = { rate_micros: rate };
169
+ if (r.takerParams.round_step_micros !== undefined)
170
+ params.round_step_micros = r.takerParams.round_step_micros;
171
+ return takerFeeRaw({ ...r, formula: "quadratic", takerParams: params, makerRebateParams: {} }, sizeRaw, notionalRaw, decimals);
172
+ }
173
+ function inForce(r, at) {
174
+ return r.effectiveFrom <= at && (r.effectiveTo === null || at < r.effectiveTo);
175
+ }
176
+ /**
177
+ * The row in force for a fill of venue at time at (microseconds, a Date or
178
+ * an ISO string): the market's fee_category if a row has it, else the row
179
+ * with category *; of several, the latest effective_from. Undefined when no
180
+ * row applies.
181
+ */
182
+ function selectFeeRow(rows, venue, category, at) {
183
+ const t = typeof at === "bigint" ? at : (0, exact_js_1.parseMicros)(at, "at");
184
+ const all = [...rows].map(feeRowOf);
185
+ const wanted = category && category !== exports.FALLBACK_CATEGORY ? [category, exports.FALLBACK_CATEGORY] : [exports.FALLBACK_CATEGORY];
186
+ for (const cat of wanted) {
187
+ let best;
188
+ for (const r of all) {
189
+ if (r.venue === venue && r.category === cat && inForce(r, t) && (best === undefined || r.effectiveFrom > best.effectiveFrom))
190
+ best = r;
191
+ }
192
+ if (best)
193
+ return best;
194
+ }
195
+ return undefined;
196
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * sk.geoblock: whether a venue would accept orders from this machine's
3
+ * network location, as the venue itself says (ARCHITECTURE 13.3).
4
+ *
5
+ * const result = await geoblock.polymarket();
6
+ * if (result.status !== "allowed") {
7
+ * // do not route this user's orders to Polymarket
8
+ * }
9
+ *
10
+ * It asks the venue, not Skewtape, and answers "unknown" on any failure: a
11
+ * network error, a timeout, an unexpected status or body. It never answers
12
+ * "allowed" unless the venue said so. The developer is responsible for their
13
+ * users: this is one check for the machine it runs on, not a licence, and it
14
+ * says nothing about the venue's terms or the law where the user is.
15
+ */
16
+ /**
17
+ * GET https://polymarket.com/api/geoblock answers {"blocked", "ip", "country",
18
+ * "region"} ("This endpoint is on polymarket.com, not the API servers",
19
+ * docs.polymarket.com/api-reference/geoblock.md, read 14 Nov 2026). The page
20
+ * lists blocked and close-only jurisdictions and does not say how close-only
21
+ * ones answer, so "allowed" means only that the venue answered blocked false.
22
+ */
23
+ export declare const POLYMARKET_GEOBLOCK_URL = "https://polymarket.com/api/geoblock";
24
+ export declare const GEOBLOCK_DEFAULT_TIMEOUT_MS = 5000;
25
+ export interface GeoblockResult {
26
+ /** "allowed" (the venue answered blocked false), "blocked" (blocked true), or "unknown" (anything else; detail says why). */
27
+ status: "allowed" | "blocked" | "unknown";
28
+ allowed: boolean;
29
+ detail: string;
30
+ /** ISO 3166-1 alpha-2, as the venue gave it. */
31
+ country?: string;
32
+ region?: string;
33
+ ip?: string;
34
+ }
35
+ export interface GeoblockOptions {
36
+ /** A fetch to use (tests pass one); the global fetch by default. */
37
+ fetch?: typeof fetch;
38
+ timeoutMs?: number;
39
+ }
40
+ /**
41
+ * Ask Polymarket whether it would take orders from this machine's network
42
+ * location. Sends nothing but the request: no Skewtape key, no order.
43
+ */
44
+ export declare function polymarketGeoblock(options?: GeoblockOptions): Promise<GeoblockResult>;
45
+ /** sk.geoblock: one helper per venue that publishes a check. */
46
+ export declare const geoblock: {
47
+ readonly polymarket: typeof polymarketGeoblock;
48
+ };
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /**
3
+ * sk.geoblock: whether a venue would accept orders from this machine's
4
+ * network location, as the venue itself says (ARCHITECTURE 13.3).
5
+ *
6
+ * const result = await geoblock.polymarket();
7
+ * if (result.status !== "allowed") {
8
+ * // do not route this user's orders to Polymarket
9
+ * }
10
+ *
11
+ * It asks the venue, not Skewtape, and answers "unknown" on any failure: a
12
+ * network error, a timeout, an unexpected status or body. It never answers
13
+ * "allowed" unless the venue said so. The developer is responsible for their
14
+ * users: this is one check for the machine it runs on, not a licence, and it
15
+ * says nothing about the venue's terms or the law where the user is.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.geoblock = exports.GEOBLOCK_DEFAULT_TIMEOUT_MS = exports.POLYMARKET_GEOBLOCK_URL = void 0;
19
+ exports.polymarketGeoblock = polymarketGeoblock;
20
+ /**
21
+ * GET https://polymarket.com/api/geoblock answers {"blocked", "ip", "country",
22
+ * "region"} ("This endpoint is on polymarket.com, not the API servers",
23
+ * docs.polymarket.com/api-reference/geoblock.md, read 14 Nov 2026). The page
24
+ * lists blocked and close-only jurisdictions and does not say how close-only
25
+ * ones answer, so "allowed" means only that the venue answered blocked false.
26
+ */
27
+ exports.POLYMARKET_GEOBLOCK_URL = "https://polymarket.com/api/geoblock";
28
+ exports.GEOBLOCK_DEFAULT_TIMEOUT_MS = 5000;
29
+ const text = (v) => (typeof v === "string" && v ? v : undefined);
30
+ function unknown(detail) {
31
+ return { status: "unknown", allowed: false, detail };
32
+ }
33
+ /**
34
+ * Ask Polymarket whether it would take orders from this machine's network
35
+ * location. Sends nothing but the request: no Skewtape key, no order.
36
+ */
37
+ async function polymarketGeoblock(options = {}) {
38
+ const doFetch = options.fetch ?? globalThis.fetch;
39
+ try {
40
+ // A redirect is not followed: the answer must be polymarket.com's own,
41
+ // as the Python SDK's httpx client follows none.
42
+ const response = await doFetch(exports.POLYMARKET_GEOBLOCK_URL, {
43
+ method: "GET",
44
+ redirect: "manual",
45
+ signal: AbortSignal.timeout(options.timeoutMs ?? exports.GEOBLOCK_DEFAULT_TIMEOUT_MS),
46
+ });
47
+ if (response.type === "opaqueredirect")
48
+ return unknown("a redirect, not followed");
49
+ if (response.status !== 200)
50
+ return unknown(`HTTP ${response.status}`);
51
+ const body = await response.json();
52
+ if (typeof body !== "object" || body === null || Array.isArray(body) || typeof body.blocked !== "boolean") {
53
+ return unknown("the reply carries no boolean blocked field");
54
+ }
55
+ const b = body;
56
+ const result = {
57
+ status: b.blocked ? "blocked" : "allowed",
58
+ allowed: !b.blocked,
59
+ detail: b.blocked ? "the venue answered blocked" : "the venue answered not blocked",
60
+ };
61
+ const country = text(b.country);
62
+ const region = text(b.region);
63
+ const ip = text(b.ip);
64
+ if (country)
65
+ result.country = country;
66
+ if (region)
67
+ result.region = region;
68
+ if (ip)
69
+ result.ip = ip;
70
+ return result;
71
+ }
72
+ catch (err) {
73
+ // Any failure is unknown, never allowed.
74
+ return unknown(err instanceof Error ? `${err.name}: ${err.message}` : String(err));
75
+ }
76
+ }
77
+ /** sk.geoblock: one helper per venue that publishes a check. */
78
+ exports.geoblock = { polymarket: polymarketGeoblock };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Skewtape: prediction-market data across venues in one schema.
3
+ *
4
+ * import { Skewtape } from "skewtape";
5
+ * const sk = new Skewtape(); // the key from SKEWTAPE_API_KEY, or { apiKey }
6
+ * for await (const event of sk.events({ minConfidence: 0.9, resolutionEqual: true })) {
7
+ * console.log(event.event_id, event.question_canonical);
8
+ * }
9
+ *
10
+ * sk.kalshi() is the optional live Kalshi client under the user's own Kalshi
11
+ * membership (src/kalshi.ts), apart from the API: Skewtape's Kalshi data
12
+ * comes from the calls above.
13
+ *
14
+ * The hand-written facade lives in src/; src/generated/schema.d.ts is
15
+ * generated from the OpenAPI document and never edited.
16
+ */
17
+ export { DEFAULT_BASE_URL, ENV_API_KEY, Paginated, Skewtape, activeMembers, type Bundle, type BundleDownloadOptions, type BundleFile, type Candle, type CandlesOptions, type DownloadURL, type EventsOptions, type Fee, type FeesOptions, type Fill, type FillsOptions, type Market, type MarketsOptions, type MatchedEvent, type MatchedEventMember, type Page, type Resolution, type ResolutionsOptions, type SkBacktestOptions, type SkewtapeOptions, type Venue, } from "./client.js";
18
+ export { BacktestError, backtestToJSON, runBacktest, type BacktestOptions, type BacktestResult, type BacktestWarning, type PositionResult, type Totals, type Trade, type TradeResult, } from "./backtest.js";
19
+ export { downloadFile, verifyChecksums, type DownloadOptions } from "./download.js";
20
+ export { Rat, fractionStr, roundHalfUp } from "./exact.js";
21
+ export { FeeError, feeRowOf, makerFeeRaw, microsToRaw, selectFeeRow, takerFeeRaw, type FeeRow, type FeeRowInput } from "./fees.js";
22
+ export { DEFAULT_KALSHI_BASE_URL, KALSHI_VENUES, Kalshi, KalshiError, PERIODS, kalshiTickers, seriesTickerOf, type KalshiCandlestick, type KalshiCandlesticksOptions, type KalshiEventLike, type KalshiLevel, type KalshiMarket, type KalshiMarketsOptions, type KalshiOHLC, type KalshiOptions, type KalshiOrderbook, type KalshiPeriod, type KalshiTrade, type KalshiTradesOptions, } from "./kalshi.js";
23
+ export { BookUnavailable, DEFAULT_BOOK_READERS, KALSHI_FRACTION_MICRO, quoteFromContext, readKalshiBook, readKalshiBookThroughDflow, readPolymarketBook, type BookReader, type BookRequest, type QuoteContext, type QuoteContextMember, type QuoteOptions, } from "./quote.js";
24
+ export { InvalidQuoteInputError, QuoteError, RuleMismatchError, VenueUnreachableError, computeQuote, type Book, type Leg, type Level, type QuoteInput, type QuoteResult, type Skip, type VenueQuote, } from "./quote-math.js";
25
+ export { AuthenticationError, BlockedError, ChecksumError, ConfigurationError, ForbiddenPlanError, InvalidRequestError, NotFoundError, QuotaExceededError, RateLimitError, ServerError, SkewtapeError, } from "./errors.js";
26
+ export { DFLOW_TRADING_API, DFlowOrderRequest, POLYMARKET_EXCHANGES, PolymarketOrder, RouteError, route, type DFlowRoute, type PolymarketRoute, type PolymarketTypedData, type RouteInput, } from "./route.js";
27
+ export { HYPERLIQUID_EXCHANGE_URL, HYPERLIQUID_TESTNET_EXCHANGE_URL, HyperliquidApproveBuilderFee, HyperliquidOrder, hyperliquidApproveBuilderFee, type HyperliquidRoute, } from "./route-hyperliquid.js";
28
+ export { geoblock, type GeoblockResult, type GeoblockOptions } from "./geoblock.js";
29
+ export { Stream, feedUrl, type FeedMessage, type FeedSocket, type FeedSocketConstructor, type StreamOptions } from "./stream.js";
30
+ export { VERSION } from "./version.js";
31
+ export type { components, paths } from "./generated/schema.js";
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ /**
3
+ * Skewtape: prediction-market data across venues in one schema.
4
+ *
5
+ * import { Skewtape } from "skewtape";
6
+ * const sk = new Skewtape(); // the key from SKEWTAPE_API_KEY, or { apiKey }
7
+ * for await (const event of sk.events({ minConfidence: 0.9, resolutionEqual: true })) {
8
+ * console.log(event.event_id, event.question_canonical);
9
+ * }
10
+ *
11
+ * sk.kalshi() is the optional live Kalshi client under the user's own Kalshi
12
+ * membership (src/kalshi.ts), apart from the API: Skewtape's Kalshi data
13
+ * comes from the calls above.
14
+ *
15
+ * The hand-written facade lives in src/; src/generated/schema.d.ts is
16
+ * generated from the OpenAPI document and never edited.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.DFLOW_TRADING_API = exports.SkewtapeError = exports.ServerError = exports.RateLimitError = exports.QuotaExceededError = exports.NotFoundError = exports.InvalidRequestError = exports.ForbiddenPlanError = exports.ConfigurationError = exports.ChecksumError = exports.BlockedError = exports.AuthenticationError = exports.computeQuote = exports.VenueUnreachableError = exports.RuleMismatchError = exports.QuoteError = exports.InvalidQuoteInputError = exports.readPolymarketBook = exports.readKalshiBookThroughDflow = exports.readKalshiBook = exports.quoteFromContext = exports.KALSHI_FRACTION_MICRO = exports.DEFAULT_BOOK_READERS = exports.BookUnavailable = exports.seriesTickerOf = exports.kalshiTickers = exports.PERIODS = exports.KalshiError = exports.Kalshi = exports.KALSHI_VENUES = exports.DEFAULT_KALSHI_BASE_URL = exports.takerFeeRaw = exports.selectFeeRow = exports.microsToRaw = exports.makerFeeRaw = exports.feeRowOf = exports.FeeError = exports.roundHalfUp = exports.fractionStr = exports.Rat = exports.verifyChecksums = exports.downloadFile = exports.runBacktest = exports.backtestToJSON = exports.BacktestError = exports.activeMembers = exports.Skewtape = exports.Paginated = exports.ENV_API_KEY = exports.DEFAULT_BASE_URL = void 0;
20
+ exports.VERSION = exports.feedUrl = exports.Stream = exports.geoblock = exports.hyperliquidApproveBuilderFee = exports.HyperliquidOrder = exports.HyperliquidApproveBuilderFee = exports.HYPERLIQUID_TESTNET_EXCHANGE_URL = exports.HYPERLIQUID_EXCHANGE_URL = exports.route = exports.RouteError = exports.PolymarketOrder = exports.POLYMARKET_EXCHANGES = exports.DFlowOrderRequest = void 0;
21
+ var client_js_1 = require("./client.js");
22
+ Object.defineProperty(exports, "DEFAULT_BASE_URL", { enumerable: true, get: function () { return client_js_1.DEFAULT_BASE_URL; } });
23
+ Object.defineProperty(exports, "ENV_API_KEY", { enumerable: true, get: function () { return client_js_1.ENV_API_KEY; } });
24
+ Object.defineProperty(exports, "Paginated", { enumerable: true, get: function () { return client_js_1.Paginated; } });
25
+ Object.defineProperty(exports, "Skewtape", { enumerable: true, get: function () { return client_js_1.Skewtape; } });
26
+ Object.defineProperty(exports, "activeMembers", { enumerable: true, get: function () { return client_js_1.activeMembers; } });
27
+ var backtest_js_1 = require("./backtest.js");
28
+ Object.defineProperty(exports, "BacktestError", { enumerable: true, get: function () { return backtest_js_1.BacktestError; } });
29
+ Object.defineProperty(exports, "backtestToJSON", { enumerable: true, get: function () { return backtest_js_1.backtestToJSON; } });
30
+ Object.defineProperty(exports, "runBacktest", { enumerable: true, get: function () { return backtest_js_1.runBacktest; } });
31
+ var download_js_1 = require("./download.js");
32
+ Object.defineProperty(exports, "downloadFile", { enumerable: true, get: function () { return download_js_1.downloadFile; } });
33
+ Object.defineProperty(exports, "verifyChecksums", { enumerable: true, get: function () { return download_js_1.verifyChecksums; } });
34
+ var exact_js_1 = require("./exact.js");
35
+ Object.defineProperty(exports, "Rat", { enumerable: true, get: function () { return exact_js_1.Rat; } });
36
+ Object.defineProperty(exports, "fractionStr", { enumerable: true, get: function () { return exact_js_1.fractionStr; } });
37
+ Object.defineProperty(exports, "roundHalfUp", { enumerable: true, get: function () { return exact_js_1.roundHalfUp; } });
38
+ var fees_js_1 = require("./fees.js");
39
+ Object.defineProperty(exports, "FeeError", { enumerable: true, get: function () { return fees_js_1.FeeError; } });
40
+ Object.defineProperty(exports, "feeRowOf", { enumerable: true, get: function () { return fees_js_1.feeRowOf; } });
41
+ Object.defineProperty(exports, "makerFeeRaw", { enumerable: true, get: function () { return fees_js_1.makerFeeRaw; } });
42
+ Object.defineProperty(exports, "microsToRaw", { enumerable: true, get: function () { return fees_js_1.microsToRaw; } });
43
+ Object.defineProperty(exports, "selectFeeRow", { enumerable: true, get: function () { return fees_js_1.selectFeeRow; } });
44
+ Object.defineProperty(exports, "takerFeeRaw", { enumerable: true, get: function () { return fees_js_1.takerFeeRaw; } });
45
+ var kalshi_js_1 = require("./kalshi.js");
46
+ Object.defineProperty(exports, "DEFAULT_KALSHI_BASE_URL", { enumerable: true, get: function () { return kalshi_js_1.DEFAULT_KALSHI_BASE_URL; } });
47
+ Object.defineProperty(exports, "KALSHI_VENUES", { enumerable: true, get: function () { return kalshi_js_1.KALSHI_VENUES; } });
48
+ Object.defineProperty(exports, "Kalshi", { enumerable: true, get: function () { return kalshi_js_1.Kalshi; } });
49
+ Object.defineProperty(exports, "KalshiError", { enumerable: true, get: function () { return kalshi_js_1.KalshiError; } });
50
+ Object.defineProperty(exports, "PERIODS", { enumerable: true, get: function () { return kalshi_js_1.PERIODS; } });
51
+ Object.defineProperty(exports, "kalshiTickers", { enumerable: true, get: function () { return kalshi_js_1.kalshiTickers; } });
52
+ Object.defineProperty(exports, "seriesTickerOf", { enumerable: true, get: function () { return kalshi_js_1.seriesTickerOf; } });
53
+ var quote_js_1 = require("./quote.js");
54
+ Object.defineProperty(exports, "BookUnavailable", { enumerable: true, get: function () { return quote_js_1.BookUnavailable; } });
55
+ Object.defineProperty(exports, "DEFAULT_BOOK_READERS", { enumerable: true, get: function () { return quote_js_1.DEFAULT_BOOK_READERS; } });
56
+ Object.defineProperty(exports, "KALSHI_FRACTION_MICRO", { enumerable: true, get: function () { return quote_js_1.KALSHI_FRACTION_MICRO; } });
57
+ Object.defineProperty(exports, "quoteFromContext", { enumerable: true, get: function () { return quote_js_1.quoteFromContext; } });
58
+ Object.defineProperty(exports, "readKalshiBook", { enumerable: true, get: function () { return quote_js_1.readKalshiBook; } });
59
+ Object.defineProperty(exports, "readKalshiBookThroughDflow", { enumerable: true, get: function () { return quote_js_1.readKalshiBookThroughDflow; } });
60
+ Object.defineProperty(exports, "readPolymarketBook", { enumerable: true, get: function () { return quote_js_1.readPolymarketBook; } });
61
+ var quote_math_js_1 = require("./quote-math.js");
62
+ Object.defineProperty(exports, "InvalidQuoteInputError", { enumerable: true, get: function () { return quote_math_js_1.InvalidQuoteInputError; } });
63
+ Object.defineProperty(exports, "QuoteError", { enumerable: true, get: function () { return quote_math_js_1.QuoteError; } });
64
+ Object.defineProperty(exports, "RuleMismatchError", { enumerable: true, get: function () { return quote_math_js_1.RuleMismatchError; } });
65
+ Object.defineProperty(exports, "VenueUnreachableError", { enumerable: true, get: function () { return quote_math_js_1.VenueUnreachableError; } });
66
+ Object.defineProperty(exports, "computeQuote", { enumerable: true, get: function () { return quote_math_js_1.computeQuote; } });
67
+ var errors_js_1 = require("./errors.js");
68
+ Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_js_1.AuthenticationError; } });
69
+ Object.defineProperty(exports, "BlockedError", { enumerable: true, get: function () { return errors_js_1.BlockedError; } });
70
+ Object.defineProperty(exports, "ChecksumError", { enumerable: true, get: function () { return errors_js_1.ChecksumError; } });
71
+ Object.defineProperty(exports, "ConfigurationError", { enumerable: true, get: function () { return errors_js_1.ConfigurationError; } });
72
+ Object.defineProperty(exports, "ForbiddenPlanError", { enumerable: true, get: function () { return errors_js_1.ForbiddenPlanError; } });
73
+ Object.defineProperty(exports, "InvalidRequestError", { enumerable: true, get: function () { return errors_js_1.InvalidRequestError; } });
74
+ Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_js_1.NotFoundError; } });
75
+ Object.defineProperty(exports, "QuotaExceededError", { enumerable: true, get: function () { return errors_js_1.QuotaExceededError; } });
76
+ Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_js_1.RateLimitError; } });
77
+ Object.defineProperty(exports, "ServerError", { enumerable: true, get: function () { return errors_js_1.ServerError; } });
78
+ Object.defineProperty(exports, "SkewtapeError", { enumerable: true, get: function () { return errors_js_1.SkewtapeError; } });
79
+ var route_js_1 = require("./route.js");
80
+ Object.defineProperty(exports, "DFLOW_TRADING_API", { enumerable: true, get: function () { return route_js_1.DFLOW_TRADING_API; } });
81
+ Object.defineProperty(exports, "DFlowOrderRequest", { enumerable: true, get: function () { return route_js_1.DFlowOrderRequest; } });
82
+ Object.defineProperty(exports, "POLYMARKET_EXCHANGES", { enumerable: true, get: function () { return route_js_1.POLYMARKET_EXCHANGES; } });
83
+ Object.defineProperty(exports, "PolymarketOrder", { enumerable: true, get: function () { return route_js_1.PolymarketOrder; } });
84
+ Object.defineProperty(exports, "RouteError", { enumerable: true, get: function () { return route_js_1.RouteError; } });
85
+ Object.defineProperty(exports, "route", { enumerable: true, get: function () { return route_js_1.route; } });
86
+ var route_hyperliquid_js_1 = require("./route-hyperliquid.js");
87
+ Object.defineProperty(exports, "HYPERLIQUID_EXCHANGE_URL", { enumerable: true, get: function () { return route_hyperliquid_js_1.HYPERLIQUID_EXCHANGE_URL; } });
88
+ Object.defineProperty(exports, "HYPERLIQUID_TESTNET_EXCHANGE_URL", { enumerable: true, get: function () { return route_hyperliquid_js_1.HYPERLIQUID_TESTNET_EXCHANGE_URL; } });
89
+ Object.defineProperty(exports, "HyperliquidApproveBuilderFee", { enumerable: true, get: function () { return route_hyperliquid_js_1.HyperliquidApproveBuilderFee; } });
90
+ Object.defineProperty(exports, "HyperliquidOrder", { enumerable: true, get: function () { return route_hyperliquid_js_1.HyperliquidOrder; } });
91
+ Object.defineProperty(exports, "hyperliquidApproveBuilderFee", { enumerable: true, get: function () { return route_hyperliquid_js_1.hyperliquidApproveBuilderFee; } });
92
+ var geoblock_js_1 = require("./geoblock.js");
93
+ Object.defineProperty(exports, "geoblock", { enumerable: true, get: function () { return geoblock_js_1.geoblock; } });
94
+ var stream_js_1 = require("./stream.js");
95
+ Object.defineProperty(exports, "Stream", { enumerable: true, get: function () { return stream_js_1.Stream; } });
96
+ Object.defineProperty(exports, "feedUrl", { enumerable: true, get: function () { return stream_js_1.feedUrl; } });
97
+ var version_js_1 = require("./version.js");
98
+ Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_js_1.VERSION; } });