investing 0.1.310 → 0.1.311
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/README.md +123 -167
- package/dist/{archiver-web.es-C5dgnXMM.js → archiver-web.es-B69gABHP.js} +1 -1
- package/dist/{archiver-web.es-DLoy_R54.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/db/index.d.ts +0 -189
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/schema.d.ts +0 -200
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/events-BJOyGWeU.cjs +1 -0
- package/dist/events-OvBb8rgy.js +1 -0
- package/dist/index-D7fsk2gy.js +15 -0
- package/dist/index-_V1Ql5Es.cjs +13 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/leaders/zulu.d.ts +5 -35
- package/dist/leaders/zulu.d.ts.map +1 -1
- package/dist/live-data/dukascopy-client.d.ts +2 -19
- package/dist/live-data/dukascopy-client.d.ts.map +1 -1
- package/dist/llm/debate-generator.d.ts +0 -7
- package/dist/llm/debate-generator.d.ts.map +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/prediction/api/analytics.d.ts.map +1 -1
- package/dist/prediction/api/leaderboard.d.ts +11 -29
- package/dist/prediction/api/leaderboard.d.ts.map +1 -1
- package/dist/prediction/api/markets.d.ts.map +1 -1
- package/dist/prediction/api/prices.d.ts.map +1 -1
- package/dist/prediction/db/markets.d.ts +0 -13
- package/dist/prediction/db/markets.d.ts.map +1 -1
- package/dist/prediction/db/trade-history.d.ts +0 -35
- package/dist/prediction/db/trade-history.d.ts.map +1 -1
- package/dist/prediction/index.d.ts +0 -7
- package/dist/prediction/index.d.ts.map +1 -1
- package/dist/prediction/sync/incremental-markets.d.ts.map +1 -1
- package/dist/prediction/sync/leaderboard.d.ts +1 -1
- package/dist/prediction/sync/leaderboard.d.ts.map +1 -1
- package/dist/prediction/sync/markets.d.ts +2 -2
- package/dist/prediction/sync/markets.d.ts.map +1 -1
- package/dist/prediction/sync/orchestration.d.ts +1 -1
- package/dist/prediction/sync/trade-history.d.ts.map +1 -1
- package/dist/predictos/agents/bookmaker-agent.d.ts.map +1 -0
- package/dist/predictos/agents/event-analysis-agent.d.ts.map +1 -0
- package/dist/{prediction-markets → predictos}/agents/index.d.ts +1 -5
- 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.map +1 -0
- package/dist/{prediction-markets → predictos}/agents/polyfactual-research.d.ts +1 -1
- package/dist/predictos/agents/polyfactual-research.d.ts.map +1 -0
- package/dist/predictos/agents/polymarket-position-tracker.d.ts.map +1 -0
- package/dist/{prediction-markets → predictos}/agents/polymarket-put-order.d.ts +1 -1
- package/dist/predictos/agents/polymarket-put-order.d.ts.map +1 -0
- package/dist/predictos/agents/polymarket-updown-15-limit-order-bot.d.ts.map +1 -0
- package/dist/predictos/agents/x402-seller.d.ts.map +1 -0
- package/dist/predictos/ai/callBlockRun.d.ts.map +1 -0
- package/dist/predictos/ai/callGrok.d.ts.map +1 -0
- package/dist/predictos/ai/callOpenAI.d.ts.map +1 -0
- package/dist/predictos/ai/http.d.ts.map +1 -0
- package/dist/{prediction-markets → predictos}/ai/index.d.ts +1 -1
- 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.map +1 -0
- package/dist/predictos/ai/prompts/arbitrageAnalysis.d.ts.map +1 -0
- package/dist/predictos/ai/prompts/bookmakerAnalysis.d.ts.map +1 -0
- package/dist/predictos/ai/prompts/searchQueryGenerator.d.ts.map +1 -0
- package/dist/predictos/ai/types.d.ts.map +1 -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/{prediction-markets → predictos}/clients/polyfactual.d.ts +1 -1
- package/dist/predictos/clients/polyfactual.d.ts.map +1 -0
- package/dist/{prediction-markets → predictos}/clients/polymarket.d.ts +1 -1
- package/dist/predictos/clients/polymarket.d.ts.map +1 -0
- package/dist/{prediction-markets → predictos}/clients/x402.d.ts +1 -1
- package/dist/predictos/clients/x402.d.ts.map +1 -0
- package/dist/{prediction-markets → predictos}/data/kalshi.d.ts +1 -1
- 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/{prediction-markets → predictos}/data/polymarket.d.ts +1 -1
- 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.map +1 -0
- package/dist/{prediction-markets → predictos}/index.d.ts +5 -8
- package/dist/predictos/index.d.ts.map +1 -0
- package/dist/predictos/index.js +1 -0
- package/dist/predictos/index.mjs +1 -0
- package/dist/{prediction-markets → predictos}/types.d.ts +6 -121
- package/dist/predictos/types.d.ts.map +1 -0
- package/dist/searchQueryGenerator-DIIs9xw5.js +1 -0
- package/dist/searchQueryGenerator-rCVblXJS.cjs +1 -0
- package/dist/stocks/index.d.ts +1 -2
- package/dist/stocks/index.d.ts.map +1 -1
- package/dist/stocks/quote-cache-service.d.ts +2 -11
- package/dist/stocks/quote-cache-service.d.ts.map +1 -1
- package/dist/stocks/unified-quote-service.d.ts +6 -15
- package/dist/stocks/unified-quote-service.d.ts.map +1 -1
- package/dist/stocks/yahoo-finance-wrapper.d.ts +6 -75
- package/dist/stocks/yahoo-finance-wrapper.d.ts.map +1 -1
- package/dist/trading-agents/agents/debate-facilitator.d.ts +3 -3
- package/dist/trading-agents/agents/debate-facilitator.d.ts.map +1 -1
- package/dist/trading-agents/agents/fund-manager.d.ts +2 -4
- package/dist/trading-agents/agents/fund-manager.d.ts.map +1 -1
- package/dist/trading-agents/agents/improved-researchers.d.ts +3 -3
- package/dist/trading-agents/agents/improved-researchers.d.ts.map +1 -1
- package/dist/trading-agents/agents/market-analyst.d.ts +2 -2
- package/dist/trading-agents/agents/market-analyst.d.ts.map +1 -1
- package/dist/trading-agents/agents/news-analyst.d.ts +2 -2
- package/dist/trading-agents/agents/news-analyst.d.ts.map +1 -1
- package/dist/trading-agents/agents/researchers.d.ts +4 -4
- package/dist/trading-agents/agents/researchers.d.ts.map +1 -1
- package/dist/trading-agents/agents/risk-team.d.ts +4 -4
- package/dist/trading-agents/agents/risk-team.d.ts.map +1 -1
- package/dist/trading-agents/agents/trader.d.ts +2 -2
- package/dist/trading-agents/agents/trader.d.ts.map +1 -1
- package/dist/trading-agents/graph/trading-graph.d.ts +2 -28
- package/dist/trading-agents/graph/trading-graph.d.ts.map +1 -1
- package/dist/trading-agents/index.d.ts +0 -4
- package/dist/trading-agents/index.d.ts.map +1 -1
- package/dist/trading-agents/types/index.d.ts +4 -27
- package/dist/trading-agents/types/index.d.ts.map +1 -1
- package/dist/trading-agents/utils/llm-client.d.ts +1 -4
- package/dist/trading-agents/utils/llm-client.d.ts.map +1 -1
- package/package.json +50 -21
- package/THIRD_PARTY_NOTICES.md +0 -144
- package/dist/index-6F5HGB0V.js +0 -15
- package/dist/index-kfghRBr2.cjs +0 -13
- package/dist/prediction/analysis/polymarket-wallet-trust.d.ts +0 -60
- package/dist/prediction/analysis/polymarket-wallet-trust.d.ts.map +0 -1
- package/dist/prediction/analysis/position-reconstruction.d.ts +0 -130
- package/dist/prediction/analysis/position-reconstruction.d.ts.map +0 -1
- package/dist/prediction/analysis/position-settlement.d.ts +0 -99
- package/dist/prediction/analysis/position-settlement.d.ts.map +0 -1
- package/dist/prediction/analysis/r-multiple.d.ts +0 -159
- package/dist/prediction/analysis/r-multiple.d.ts.map +0 -1
- package/dist/prediction/analysis/trust-score.d.ts +0 -158
- package/dist/prediction/analysis/trust-score.d.ts.map +0 -1
- package/dist/prediction/sync/refill-limits.d.ts +0 -9
- package/dist/prediction/sync/refill-limits.d.ts.map +0 -1
- package/dist/prediction/sync/refill.d.ts +0 -34
- package/dist/prediction/sync/refill.d.ts.map +0 -1
- package/dist/prediction/utils/token-ids.d.ts +0 -17
- package/dist/prediction/utils/token-ids.d.ts.map +0 -1
- package/dist/prediction-markets/adapters/trading-agents.d.ts +0 -21
- package/dist/prediction-markets/adapters/trading-agents.d.ts.map +0 -1
- package/dist/prediction-markets/agents/bookmaker-agent.d.ts.map +0 -1
- package/dist/prediction-markets/agents/event-analysis-agent.d.ts.map +0 -1
- package/dist/prediction-markets/agents/index.d.ts.map +0 -1
- package/dist/prediction-markets/agents/kalshi-momentum-agent.d.ts +0 -7
- package/dist/prediction-markets/agents/kalshi-momentum-agent.d.ts.map +0 -1
- package/dist/prediction-markets/agents/mapper-agent.d.ts.map +0 -1
- package/dist/prediction-markets/agents/polyfactual-research.d.ts.map +0 -1
- package/dist/prediction-markets/agents/polymarket-position-tracker.d.ts.map +0 -1
- package/dist/prediction-markets/agents/polymarket-put-order.d.ts.map +0 -1
- package/dist/prediction-markets/agents/polymarket-updown-15-limit-order-bot.d.ts.map +0 -1
- package/dist/prediction-markets/agents/x402-seller.d.ts.map +0 -1
- package/dist/prediction-markets/ai/callBlockRun.d.ts.map +0 -1
- package/dist/prediction-markets/ai/callGrok.d.ts.map +0 -1
- package/dist/prediction-markets/ai/callOpenAI.d.ts.map +0 -1
- package/dist/prediction-markets/ai/http.d.ts.map +0 -1
- package/dist/prediction-markets/ai/index.d.ts.map +0 -1
- package/dist/prediction-markets/ai/prompts/analyzeEventMarkets.d.ts.map +0 -1
- package/dist/prediction-markets/ai/prompts/arbitrageAnalysis.d.ts.map +0 -1
- package/dist/prediction-markets/ai/prompts/bookmakerAnalysis.d.ts.map +0 -1
- package/dist/prediction-markets/ai/prompts/searchQueryGenerator.d.ts.map +0 -1
- package/dist/prediction-markets/ai/types.d.ts.map +0 -1
- package/dist/prediction-markets/arbitrage.d.ts.map +0 -1
- package/dist/prediction-markets/clients/polyfactual.d.ts.map +0 -1
- package/dist/prediction-markets/clients/polymarket.d.ts.map +0 -1
- package/dist/prediction-markets/clients/x402.d.ts.map +0 -1
- package/dist/prediction-markets/data/kalshi.d.ts.map +0 -1
- package/dist/prediction-markets/data/polymarket.d.ts.map +0 -1
- package/dist/prediction-markets/events.d.ts.map +0 -1
- package/dist/prediction-markets/execution/paper.d.ts +0 -19
- package/dist/prediction-markets/execution/paper.d.ts.map +0 -1
- package/dist/prediction-markets/index.cjs +0 -1
- package/dist/prediction-markets/index.d.ts.map +0 -1
- package/dist/prediction-markets/index.mjs +0 -1
- package/dist/prediction-markets/kalshi-momentum.LICENSE +0 -21
- package/dist/prediction-markets/strategies/btc15m-fusion.d.ts +0 -27
- package/dist/prediction-markets/strategies/btc15m-fusion.d.ts.map +0 -1
- package/dist/prediction-markets/strategies/copy-trade-sizing.d.ts +0 -27
- package/dist/prediction-markets/strategies/copy-trade-sizing.d.ts.map +0 -1
- package/dist/prediction-markets/strategies/gabagool.d.ts +0 -26
- package/dist/prediction-markets/strategies/gabagool.d.ts.map +0 -1
- package/dist/prediction-markets/strategies/kalshi-momentum.d.ts +0 -13
- package/dist/prediction-markets/strategies/kalshi-momentum.d.ts.map +0 -1
- package/dist/prediction-markets/types.d.ts.map +0 -1
- package/dist/prediction-markets/validation.d.ts +0 -5
- package/dist/prediction-markets/validation.d.ts.map +0 -1
- package/dist/scripted-llm-B-UTs08L.js +0 -1
- package/dist/scripted-llm-CmDVkhyH.cjs +0 -1
- package/dist/stocks/strategies/bb-rsi-breakout.d.ts +0 -63
- package/dist/stocks/strategies/bb-rsi-breakout.d.ts.map +0 -1
- package/dist/stocks/strategies/ema-crossover.d.ts +0 -51
- package/dist/stocks/strategies/ema-crossover.d.ts.map +0 -1
- package/dist/strategy-signals/data/fixture-data-provider.d.ts +0 -8
- package/dist/strategy-signals/data/fixture-data-provider.d.ts.map +0 -1
- package/dist/strategy-signals/data/openbb-mapping.d.ts +0 -7
- package/dist/strategy-signals/data/openbb-mapping.d.ts.map +0 -1
- package/dist/strategy-signals/demo.d.ts +0 -446
- package/dist/strategy-signals/demo.d.ts.map +0 -1
- package/dist/strategy-signals/execution.d.ts +0 -18
- package/dist/strategy-signals/execution.d.ts.map +0 -1
- package/dist/strategy-signals/fixtures/openbb-data/bars.d.ts +0 -10
- package/dist/strategy-signals/fixtures/openbb-data/bars.d.ts.map +0 -1
- package/dist/strategy-signals/index.d.ts +0 -36
- package/dist/strategy-signals/index.d.ts.map +0 -1
- package/dist/strategy-signals/indicators/spread-aware-momentum.d.ts +0 -31
- package/dist/strategy-signals/indicators/spread-aware-momentum.d.ts.map +0 -1
- package/dist/strategy-signals/proposal.d.ts +0 -10
- package/dist/strategy-signals/proposal.d.ts.map +0 -1
- package/dist/strategy-signals/report.d.ts +0 -6
- package/dist/strategy-signals/report.d.ts.map +0 -1
- package/dist/strategy-signals/risk-gate.d.ts +0 -3
- package/dist/strategy-signals/risk-gate.d.ts.map +0 -1
- package/dist/strategy-signals/sources/btc15m-fusion.d.ts +0 -16
- package/dist/strategy-signals/sources/btc15m-fusion.d.ts.map +0 -1
- package/dist/strategy-signals/sources/copy-trade-sizing.d.ts +0 -15
- package/dist/strategy-signals/sources/copy-trade-sizing.d.ts.map +0 -1
- package/dist/strategy-signals/sources/gabagool.d.ts +0 -12
- package/dist/strategy-signals/sources/gabagool.d.ts.map +0 -1
- package/dist/strategy-signals/sources/hedge-fund-technicals.d.ts +0 -42
- package/dist/strategy-signals/sources/hedge-fund-technicals.d.ts.map +0 -1
- package/dist/strategy-signals/sources/kalshi-momentum.d.ts +0 -10
- package/dist/strategy-signals/sources/kalshi-momentum.d.ts.map +0 -1
- package/dist/strategy-signals/sources/kalshi-vibe-guards.d.ts +0 -15
- package/dist/strategy-signals/sources/kalshi-vibe-guards.d.ts.map +0 -1
- package/dist/strategy-signals/sources/kalshi-vibe.d.ts +0 -11
- package/dist/strategy-signals/sources/kalshi-vibe.d.ts.map +0 -1
- package/dist/strategy-signals/sources/red-flags.d.ts +0 -13
- package/dist/strategy-signals/sources/red-flags.d.ts.map +0 -1
- package/dist/strategy-signals/sources/spread-aware-momentum.d.ts +0 -11
- package/dist/strategy-signals/sources/spread-aware-momentum.d.ts.map +0 -1
- package/dist/strategy-signals/survival-posture.d.ts +0 -13
- package/dist/strategy-signals/survival-posture.d.ts.map +0 -1
- package/dist/strategy-signals/types.d.ts +0 -138
- package/dist/strategy-signals/types.d.ts.map +0 -1
- package/dist/strategy-signals/validate.d.ts +0 -15
- package/dist/strategy-signals/validate.d.ts.map +0 -1
- package/dist/strategy-signals/venues/kalshi-venue-mapping.d.ts +0 -3
- package/dist/strategy-signals/venues/kalshi-venue-mapping.d.ts.map +0 -1
- package/dist/strategy-signals/venues/mock-equity-broker.d.ts +0 -16
- package/dist/strategy-signals/venues/mock-equity-broker.d.ts.map +0 -1
- package/dist/strategy-signals/venues/mock-venue.d.ts +0 -14
- package/dist/strategy-signals/venues/mock-venue.d.ts.map +0 -1
- package/dist/strategy-signals/venues/pmxt-venue-mapping.d.ts +0 -7
- package/dist/strategy-signals/venues/pmxt-venue-mapping.d.ts.map +0 -1
- package/dist/trading-agents/agents/risk-judge.d.ts +0 -13
- package/dist/trading-agents/agents/risk-judge.d.ts.map +0 -1
- package/dist/trading-agents/index.cjs +0 -1
- package/dist/trading-agents/index.mjs +0 -1
- package/dist/trading-agents/utils/parse-final-line.d.ts +0 -7
- package/dist/trading-agents/utils/parse-final-line.d.ts.map +0 -1
- package/dist/trading-agents/utils/scripted-llm.d.ts +0 -17
- package/dist/trading-agents/utils/scripted-llm.d.ts.map +0 -1
- package/dist/trading-agents/utils/strategy-prompt.d.ts +0 -6
- package/dist/trading-agents/utils/strategy-prompt.d.ts.map +0 -1
- package/dist/trading-agents-Bh9OORHe.js +0 -1
- package/dist/trading-agents-C8M7tbB0.cjs +0 -1
- package/dist/validate-C1MS8RhG.js +0 -1
- package/dist/validate-DBxPUXqH.cjs +0 -1
- /package/dist/{prediction-markets → predictos}/agents/bookmaker-agent.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/agents/event-analysis-agent.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/agents/mapper-agent.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/agents/polymarket-position-tracker.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/agents/polymarket-updown-15-limit-order-bot.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/agents/x402-seller.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/ai/callBlockRun.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/ai/callGrok.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/ai/callOpenAI.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/ai/http.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/ai/prompts/analyzeEventMarkets.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/ai/prompts/arbitrageAnalysis.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/ai/prompts/bookmakerAnalysis.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/ai/prompts/searchQueryGenerator.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/ai/types.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/arbitrage.d.ts +0 -0
- /package/dist/{prediction-markets → predictos}/events.d.ts +0 -0
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { ExcludedPosition, RMultipleExclusionReason } from './r-multiple';
|
|
2
|
-
import { SettledPosition } from './position-settlement';
|
|
3
|
-
import { ReconstructionSkip } from './position-reconstruction';
|
|
4
|
-
import { ForecasterTrustScore, ForecasterTrustScoreOptions } from './trust-score';
|
|
5
|
-
/** The database-shaped fields required by the pure wallet-history adapter. */
|
|
6
|
-
export interface StoredWalletTradeRow {
|
|
7
|
-
id: string;
|
|
8
|
-
traderId: string;
|
|
9
|
-
conditionId: string;
|
|
10
|
-
type: string;
|
|
11
|
-
side: string | null;
|
|
12
|
-
outcomeIndex: number | null;
|
|
13
|
-
size: number;
|
|
14
|
-
usdcSize: number;
|
|
15
|
-
/** Drizzle `integer(..., { mode: "timestamp" })` returns a Date. */
|
|
16
|
-
timestamp: Date;
|
|
17
|
-
}
|
|
18
|
-
export interface PolymarketWalletTrustOptions extends ForecasterTrustScoreOptions {
|
|
19
|
-
/** Passed to the existing R-multiple converter. Defaults to zero. */
|
|
20
|
-
minInitialRisk?: number;
|
|
21
|
-
}
|
|
22
|
-
export interface PolymarketWalletTrustInputs {
|
|
23
|
-
wallet: {
|
|
24
|
-
kind: "polymarket-proxy-wallet";
|
|
25
|
-
id: string;
|
|
26
|
-
};
|
|
27
|
-
/** Inclusive historical cutoff, in epoch seconds. */
|
|
28
|
-
cutoff: number;
|
|
29
|
-
/** Explicitly prevents this partial record from being presented as complete. */
|
|
30
|
-
coverage: {
|
|
31
|
-
basis: "sell-closed-only";
|
|
32
|
-
historyCompleteness: "unknown";
|
|
33
|
-
resolutionEvidence: "none";
|
|
34
|
-
};
|
|
35
|
-
/** SELL-closed and unresolved residual episodes produced by settlement. */
|
|
36
|
-
positions: SettledPosition[];
|
|
37
|
-
/** Rows/groups rejected by conservative reconstruction validation. */
|
|
38
|
-
reconstructionSkips: ReconstructionSkip[];
|
|
39
|
-
/** Finite R-multiples from SELL-closed positions only. */
|
|
40
|
-
rMultiples: number[];
|
|
41
|
-
includedPositions: number;
|
|
42
|
-
rMultipleExclusions: ExcludedPosition[];
|
|
43
|
-
rMultipleExclusionCounts: Record<RMultipleExclusionReason, number>;
|
|
44
|
-
trust: ForecasterTrustScore;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Purely converts stored wallet rows into R-multiples and a TRUST result.
|
|
48
|
-
*
|
|
49
|
-
* Raw rows are cutoff-filtered before settlement. A valid future row therefore
|
|
50
|
-
* cannot close, oversell, or poison an episode as it existed at the cutoff.
|
|
51
|
-
* Invalid numeric fields are passed through unchanged and are conservatively
|
|
52
|
-
* reported by settlement; this adapter never coerces them to zero.
|
|
53
|
-
*/
|
|
54
|
-
export declare function buildPolymarketWalletTrustInputs(walletId: string, cutoff: number, rows: readonly StoredWalletTradeRow[], options?: PolymarketWalletTrustOptions): PolymarketWalletTrustInputs;
|
|
55
|
-
/**
|
|
56
|
-
* Loads all locally stored TRADE rows for a wallet through `cutoff`, then runs
|
|
57
|
-
* the pure SELL-closed-only adapter. Local-table completeness remains unknown.
|
|
58
|
-
*/
|
|
59
|
-
export declare function loadPolymarketWalletTrustInputs(walletId: string, cutoff: number, options?: PolymarketWalletTrustOptions): Promise<PolymarketWalletTrustInputs>;
|
|
60
|
-
//# sourceMappingURL=polymarket-wallet-trust.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polymarket-wallet-trust.d.ts","sourceRoot":"","sources":["../../../src/prediction/analysis/polymarket-wallet-trust.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC9B,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EACjC,MAAM,eAAe,CAAC;AAEvB,8EAA8E;AAC9E,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,4BACf,SAAQ,2BAA2B;IACnC,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE;QACN,IAAI,EAAE,yBAAyB,CAAC;QAChC,EAAE,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,QAAQ,EAAE;QACR,KAAK,EAAE,kBAAkB,CAAC;QAC1B,mBAAmB,EAAE,SAAS,CAAC;QAC/B,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,2EAA2E;IAC3E,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,sEAAsE;IACtE,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAC1C,0DAA0D;IAC1D,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,gBAAgB,EAAE,CAAC;IACxC,wBAAwB,EAAE,MAAM,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;IACnE,KAAK,EAAE,oBAAoB,CAAC;CAC7B;AASD;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,oBAAoB,EAAE,EACrC,OAAO,GAAE,4BAAiC,GACzC,2BAA2B,CA8D7B;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,4BAAiC,GACzC,OAAO,CAAC,2BAA2B,CAAC,CAQtC"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { ResolvedPosition } from './r-multiple';
|
|
2
|
-
/**
|
|
3
|
-
* The subset of a `polymarket_trade_history` row this reconstruction needs.
|
|
4
|
-
* Mirrors the persisted columns (see `db/schema.ts` `polymarketTradeHistory`).
|
|
5
|
-
*/
|
|
6
|
-
export interface StoredTrade {
|
|
7
|
-
/** Trader wallet address (`trader_id`). */
|
|
8
|
-
traderId: string;
|
|
9
|
-
/** Market condition id (`condition_id`). */
|
|
10
|
-
conditionId: string;
|
|
11
|
-
/** Activity type; only `"TRADE"` rows are reconstructed. */
|
|
12
|
-
type: string;
|
|
13
|
-
/** `"BUY"` or `"SELL"` for a TRADE; other values are treated as missing. */
|
|
14
|
-
side: string | null;
|
|
15
|
-
/** Outcome leg (0 or 1). */
|
|
16
|
-
outcomeIndex: number | null;
|
|
17
|
-
/** Number of shares/tokens in the fill (must be finite and > 0). */
|
|
18
|
-
size: number;
|
|
19
|
-
/** USDC cash moved by the fill (must be finite and >= 0). */
|
|
20
|
-
usdcSize: number;
|
|
21
|
-
/** Trade execution time, epoch seconds (must be finite). */
|
|
22
|
-
timestamp: number;
|
|
23
|
-
/**
|
|
24
|
-
* Optional stable row id (the `transaction_hash-outcomeIndex` primary key).
|
|
25
|
-
* Not used for ordering; carried only to make skip reports traceable.
|
|
26
|
-
*/
|
|
27
|
-
id?: string;
|
|
28
|
-
}
|
|
29
|
-
/** Why a row or group could not be reconstructed into a resolved position. */
|
|
30
|
-
export type ReconstructionSkipReason =
|
|
31
|
-
/** Row `type` is not `"TRADE"` (e.g. REDEEM/SPLIT/MERGE); not a bet fill. */
|
|
32
|
-
"non-trade-type"
|
|
33
|
-
/**
|
|
34
|
-
* A required field was missing or non-finite.
|
|
35
|
-
*
|
|
36
|
-
* For a row whose grouping key is itself usable, the WHOLE group is skipped —
|
|
37
|
-
* including any episodes in that group that had already cleanly opened and
|
|
38
|
-
* closed. This is deliberately more aggressive than the oversell policy, and
|
|
39
|
-
* the reason is that a malformed row is dropped BEFORE its timeline position
|
|
40
|
-
* is recorded, so its true place among the group's fills is unknown. An
|
|
41
|
-
* episode that looks "earlier" among the remaining valid fills might actually
|
|
42
|
-
* have had the malformed fill interleaved inside it, so no episode in the
|
|
43
|
-
* group can be proven to precede the bad row. Discarding the whole group never
|
|
44
|
-
* emits a misleading value; it only drops data we cannot place with certainty.
|
|
45
|
-
* (Contrast `oversold`, whose offending SELL has a known timestamp, so
|
|
46
|
-
* independently completed earlier episodes are retained.)
|
|
47
|
-
*
|
|
48
|
-
* For a row whose grouping key is unusable the single row is skipped (and may
|
|
49
|
-
* silently under-count its group — undetectable here).
|
|
50
|
-
*/
|
|
51
|
-
| "missing-fields"
|
|
52
|
-
/**
|
|
53
|
-
* A SELL arrived in an episode that had no recorded BUY inventory. Detected at
|
|
54
|
-
* a known point in the ordered fills, so any independently completed earlier
|
|
55
|
-
* episodes in the same group are retained.
|
|
56
|
-
*/
|
|
57
|
-
| "no-buys"
|
|
58
|
-
/**
|
|
59
|
-
* A SELL exceeded the inventory tracked so far (missing earlier BUYs).
|
|
60
|
-
* Detected at a known point in the ordered fills, so any independently
|
|
61
|
-
* completed earlier episodes in the same group are retained; only this
|
|
62
|
-
* episode onward is abandoned.
|
|
63
|
-
*/
|
|
64
|
-
| "oversold";
|
|
65
|
-
/** One skipped row or group, with the reason and a traceable key. */
|
|
66
|
-
export interface ReconstructionSkip {
|
|
67
|
-
/**
|
|
68
|
-
* Group key `traderId:conditionId:outcomeIndex` for group-level skips, or a
|
|
69
|
-
* row locator (`row <id>` / `row #<index>`) for row-level skips.
|
|
70
|
-
*/
|
|
71
|
-
key: string;
|
|
72
|
-
reason: ReconstructionSkipReason;
|
|
73
|
-
}
|
|
74
|
-
/** Result of {@link reconstructResolvedPositions}. */
|
|
75
|
-
export interface ReconstructionResult {
|
|
76
|
-
/**
|
|
77
|
-
* Reconstructed positions in deterministic order (grouped, then by episode).
|
|
78
|
-
* Fully SELL-closed episodes have `resolved: true`; a group's trailing
|
|
79
|
-
* residual inventory is emitted once with `resolved: false`. Ready to pass to
|
|
80
|
-
* `rMultiplesFromResolvedPositions`.
|
|
81
|
-
*/
|
|
82
|
-
positions: ResolvedPosition[];
|
|
83
|
-
/** Every skipped row/group, in the order encountered. */
|
|
84
|
-
skipped: ReconstructionSkip[];
|
|
85
|
-
}
|
|
86
|
-
/** Options for {@link reconstructResolvedPositions}. */
|
|
87
|
-
export interface ReconstructionOptions {
|
|
88
|
-
/**
|
|
89
|
-
* Absolute tolerance, in shares, for treating residual inventory as flat.
|
|
90
|
-
* Used ONLY to absorb floating-point dust from summing `size`:
|
|
91
|
-
* - `|inventory| <= sharesEpsilon` -> treated as exactly flat (episode closes),
|
|
92
|
-
* - `inventory < -sharesEpsilon` -> oversell,
|
|
93
|
-
* - `inventory > sharesEpsilon` -> material open inventory (stays unresolved).
|
|
94
|
-
* It never rounds away a material mismatch: anything above the epsilon is
|
|
95
|
-
* real inventory, not dust. Defaults to `1e-9`. Must be finite and >= 0.
|
|
96
|
-
*
|
|
97
|
-
* CAUTION: this is a dust tolerance, not a rounding knob. It is validated only
|
|
98
|
-
* as finite and non-negative — there is no universal upper bound, because the
|
|
99
|
-
* meaningful share scale varies by market. A caller that passes an excessively
|
|
100
|
-
* large value (e.g. tens or hundreds of shares) WILL cause genuinely material
|
|
101
|
-
* residual inventory to be classified as flat, emitting a bogus `resolved`
|
|
102
|
-
* position (and masking a real oversell). Keep it at or near the default;
|
|
103
|
-
* raise it only by an amount provably within float-summation error.
|
|
104
|
-
*/
|
|
105
|
-
sharesEpsilon?: number;
|
|
106
|
-
}
|
|
107
|
-
/** Default dust tolerance for the flat/oversell inventory test. */
|
|
108
|
-
export declare const DEFAULT_SHARES_EPSILON = 1e-9;
|
|
109
|
-
/**
|
|
110
|
-
* Reconstructs completed Polymarket positions from stored TRADE rows.
|
|
111
|
-
*
|
|
112
|
-
* Fills are grouped by `(traderId, conditionId, outcomeIndex)` and, within a
|
|
113
|
-
* group, sorted by `timestamp` ascending. TIE-BREAK: fills sharing a timestamp
|
|
114
|
-
* keep their original input order (a stable sort). Because Polymarket
|
|
115
|
-
* timestamps are second-granularity, several fills in the same second have an
|
|
116
|
-
* ambiguous true execution order; this function does not attempt to recover it,
|
|
117
|
-
* so for same-second fills the episode split (and any oversell classification)
|
|
118
|
-
* depends on the order the caller supplied. Pass rows in a consistent order
|
|
119
|
-
* (e.g. the DB's `ORDER BY timestamp, id`) for reproducible results; the
|
|
120
|
-
* function is otherwise fully deterministic and does not read the clock.
|
|
121
|
-
*
|
|
122
|
-
* @param trades - Stored trade rows (a superset of TRADE rows is fine; non-TRADE
|
|
123
|
-
* rows are reported as `non-trade-type` skips and ignored).
|
|
124
|
-
* @param options - See {@link ReconstructionOptions}.
|
|
125
|
-
* @returns A {@link ReconstructionResult}.
|
|
126
|
-
* @throws {TypeError} If `trades` is not an array.
|
|
127
|
-
* @throws {RangeError} If `sharesEpsilon` is supplied and is not finite / is negative.
|
|
128
|
-
*/
|
|
129
|
-
export declare function reconstructResolvedPositions(trades: readonly StoredTrade[], options?: ReconstructionOptions): ReconstructionResult;
|
|
130
|
-
//# sourceMappingURL=position-reconstruction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"position-reconstruction.d.ts","sourceRoot":"","sources":["../../../src/prediction/analysis/position-reconstruction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,4BAA4B;IAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,8EAA8E;AAC9E,MAAM,MAAM,wBAAwB;AAClC,6EAA6E;AAC3E,gBAAgB;AAClB;;;;;;;;;;;;;;;;;GAiBG;GACD,gBAAgB;AAClB;;;;GAIG;GACD,SAAS;AACX;;;;;GAKG;GACD,UAAU,CAAC;AAEf,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,wBAAwB,CAAC;CAClC;AAED,sDAAsD;AACtD,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,yDAAyD;IACzD,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAED,wDAAwD;AACxD,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;;;;;;;;;OAgBG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAmB3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CAkKtB"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { ResolvedPosition } from './r-multiple';
|
|
2
|
-
import { ReconstructionSkip, StoredTrade } from './position-reconstruction';
|
|
3
|
-
/**
|
|
4
|
-
* An explicit, point-in-time market resolution label for one condition. Supplied
|
|
5
|
-
* by the (impure) caller; this module never derives it from market state.
|
|
6
|
-
*/
|
|
7
|
-
export interface MarketResolution {
|
|
8
|
-
/**
|
|
9
|
-
* Index of the outcome leg that resolved true. This is a BINARY-market
|
|
10
|
-
* converter, so only `0` or `1` is accepted; any other value (a sentinel,
|
|
11
|
-
* a multi-outcome index, a garbage label) is rejected and the affected
|
|
12
|
-
* position is left unresolved rather than settled or marked a false loss.
|
|
13
|
-
*/
|
|
14
|
-
winningOutcomeIndex: number;
|
|
15
|
-
/**
|
|
16
|
-
* Epoch seconds at which the market resolved (the settlement instant). Must be
|
|
17
|
-
* at or after every fill of the settled episode — a market cannot resolve
|
|
18
|
-
* before its last contributing trade. A `resolvedAt` earlier than that leaves
|
|
19
|
-
* the position unresolved (never settled with an impossible, look-ahead time).
|
|
20
|
-
*/
|
|
21
|
-
resolvedAt: number;
|
|
22
|
-
}
|
|
23
|
-
/** How a {@link SettledPosition} reached its final state. */
|
|
24
|
-
export type PositionClosure = "sell-close" | "settlement" | "open";
|
|
25
|
-
/**
|
|
26
|
-
* A reconstructed position, tagged with how it closed. Adds fields to
|
|
27
|
-
* {@link ResolvedPosition} (so it remains assignable to it and usable directly
|
|
28
|
-
* with `rMultiplesFromResolvedPositions`) without changing that contract.
|
|
29
|
-
*/
|
|
30
|
-
export interface SettledPosition extends ResolvedPosition {
|
|
31
|
-
/** Whether this was SELL-closed, settled at resolution, or still open. */
|
|
32
|
-
closure: PositionClosure;
|
|
33
|
-
/**
|
|
34
|
-
* Residual shares at resolution — present for `"settlement"` and `"open"`
|
|
35
|
-
* positions, `undefined` for `"sell-close"` (which returned to flat).
|
|
36
|
-
*/
|
|
37
|
-
residualShares?: number;
|
|
38
|
-
}
|
|
39
|
-
/** Result of {@link settleResolvedPositions}. */
|
|
40
|
-
export interface SettlementResult {
|
|
41
|
-
/**
|
|
42
|
-
* Positions in deterministic order (grouped, then by episode). Pass directly
|
|
43
|
-
* to `rMultiplesFromResolvedPositions`; `"open"` entries are excluded there
|
|
44
|
-
* as `unresolved`.
|
|
45
|
-
*/
|
|
46
|
-
positions: SettledPosition[];
|
|
47
|
-
/** Skipped rows/groups, mirroring reconstruction's reasons. */
|
|
48
|
-
skipped: ReconstructionSkip[];
|
|
49
|
-
}
|
|
50
|
-
/** A resolution lookup keyed by `conditionId`. */
|
|
51
|
-
export type ResolutionMap = ReadonlyMap<string, MarketResolution>;
|
|
52
|
-
/** Options for {@link settleResolvedPositions}. */
|
|
53
|
-
export interface SettlementOptions {
|
|
54
|
-
/**
|
|
55
|
-
* Dust tolerance in shares for the flat/oversell inventory test. Identical in
|
|
56
|
-
* meaning to reconstruction's option: see its docs for the caution that an
|
|
57
|
-
* excessively large value misclassifies material inventory. Defaults to
|
|
58
|
-
* {@link DEFAULT_SHARES_EPSILON}. Must be finite and >= 0.
|
|
59
|
-
*/
|
|
60
|
-
sharesEpsilon?: number;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Reconstructs Polymarket positions from stored TRADE fills and settles residual
|
|
64
|
-
* inventory against explicit resolution labels.
|
|
65
|
-
*
|
|
66
|
-
* Fills are grouped by `(traderId, conditionId, outcomeIndex)` and sorted by
|
|
67
|
-
* `timestamp` (stable; equal timestamps keep input order — see
|
|
68
|
-
* {@link reconstructResolvedPositions} for the same tie-break caveat). SELL-
|
|
69
|
-
* closed episodes are emitted as `"sell-close"`. A group's trailing residual
|
|
70
|
-
* inventory is settled as `"settlement"` only when `resolutions` has a label for
|
|
71
|
-
* its `conditionId` that is both (a) a valid BINARY label — `winningOutcomeIndex`
|
|
72
|
-
* exactly 0 or 1, finite `resolvedAt` — and (b) temporally consistent —
|
|
73
|
-
* `resolvedAt` at or after the latest fill of that episode. Otherwise the
|
|
74
|
-
* residual is left `"open"` (unresolved); an unsupported index or an impossible
|
|
75
|
-
* early `resolvedAt` never produces a resolved position or a fabricated $0 loss.
|
|
76
|
-
* A fill whose `outcomeIndex` is not 0 or 1 is rejected as an invalid row
|
|
77
|
-
* (`missing-fields`), not silently grouped. A position is ever only one of these
|
|
78
|
-
* — a closed episode or the trailing residual — so it is never both SELL-closed
|
|
79
|
-
* and settlement-resolved.
|
|
80
|
-
*
|
|
81
|
-
* DE-DUPLICATION: fills are de-duplicated by the verified trade identity — the
|
|
82
|
-
* `id` field, which is the `polymarket_trade_history` primary key
|
|
83
|
-
* `transaction_hash-outcomeIndex`. Two rows sharing a non-empty `id` denote the
|
|
84
|
-
* SAME on-chain fill (the DB enforces uniqueness on it), so only the first is
|
|
85
|
-
* counted and later copies are dropped. Rows WITHOUT an `id` cannot be
|
|
86
|
-
* identified as duplicates and are each counted; de-duplicating those is a
|
|
87
|
-
* caller precondition.
|
|
88
|
-
*
|
|
89
|
-
* @param trades - Stored trade rows (non-TRADE rows are reported as
|
|
90
|
-
* `non-trade-type` skips and ignored).
|
|
91
|
-
* @param resolutions - Resolution labels keyed by `conditionId`. An empty map
|
|
92
|
-
* (or a missing/invalid entry) leaves the affected residual positions open.
|
|
93
|
-
* @param options - See {@link SettlementOptions}.
|
|
94
|
-
* @returns A {@link SettlementResult}.
|
|
95
|
-
* @throws {TypeError} If `trades` is not an array or `resolutions` is not a Map.
|
|
96
|
-
* @throws {RangeError} If `sharesEpsilon` is supplied and is not finite / is negative.
|
|
97
|
-
*/
|
|
98
|
-
export declare function settleResolvedPositions(trades: readonly StoredTrade[], resolutions: ResolutionMap, options?: SettlementOptions): SettlementResult;
|
|
99
|
-
//# sourceMappingURL=position-settlement.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"position-settlement.d.ts","sourceRoot":"","sources":["../../../src/prediction/analysis/position-settlement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,2BAA2B,CAAC;AAEnC;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,6DAA6D;AAC7D,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,YAAY,GAAG,MAAM,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,0EAA0E;IAC1E,OAAO,EAAE,eAAe,CAAC;IACzB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,+DAA+D;IAC/D,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAED,kDAAkD;AAClD,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAElE,mDAAmD;AACnD,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAkDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,WAAW,EAAE,aAAa,EAC1B,OAAO,GAAE,iBAAsB,GAC9B,gBAAgB,CA0LlB"}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* R-multiple conversion for resolved prediction-market positions.
|
|
3
|
-
*
|
|
4
|
-
* A pure, deterministic utility that turns a list of already-reconstructed,
|
|
5
|
-
* fully-realized positions into the per-trade R-multiples consumed by
|
|
6
|
-
* {@link computeForecasterTrustScore} (see `./trust-score.ts`). An R-multiple
|
|
7
|
-
* expresses a position's realized profit or loss in units of the risk taken:
|
|
8
|
-
*
|
|
9
|
-
* R = netRealizedPnl / initialRisk
|
|
10
|
-
*
|
|
11
|
-
* where `initialRisk` is the net premium paid to open the position (the most
|
|
12
|
-
* that can be lost, since a prediction-market share's downside is bounded at
|
|
13
|
-
* zero). A position that loses its entire stake therefore scores exactly -1R,
|
|
14
|
-
* matching the research paper's convention (§3.2).
|
|
15
|
-
*
|
|
16
|
-
* BOUNDARY: this module sits at the clean edge of the pipeline. It performs NO
|
|
17
|
-
* I/O, DB, network, or clock access; it does NOT reconstruct positions from raw
|
|
18
|
-
* trade history, ingest settlement/redemption events, impute resolution
|
|
19
|
-
* outcomes, size positions, or place orders. All of that is upstream, impure
|
|
20
|
-
* work that produces the {@link ResolvedPosition} array this function consumes.
|
|
21
|
-
* A `cutoff` is passed in, never read from the system clock, so the function
|
|
22
|
-
* stays referentially transparent and leak-free: a Trust Score at a historical
|
|
23
|
-
* cutoff must only see outcomes known by that cutoff, and the caller enforces
|
|
24
|
-
* that by supplying the cutoff here.
|
|
25
|
-
*
|
|
26
|
-
* Error philosophy mirrors `trust-score.ts`: malformed INPUT SHAPES throw
|
|
27
|
-
* (programmer error), while DATA-QUALITY problems in otherwise well-formed
|
|
28
|
-
* records (unresolved, non-finite financials, non-positive risk, timestamps
|
|
29
|
-
* after the cutoff) are reported as soft exclusions, never thrown and never
|
|
30
|
-
* silently coerced. Every value in the returned `rMultiples` is a finite
|
|
31
|
-
* number, so the downstream Trust Score never has to defend against NaN/Infinity.
|
|
32
|
-
*/
|
|
33
|
-
/** Why a {@link ResolvedPosition} was dropped from the R-multiple sample. */
|
|
34
|
-
export type RMultipleExclusionReason =
|
|
35
|
-
/** `resolved === false`: the position is still open / not yet realized. */
|
|
36
|
-
"unresolved"
|
|
37
|
-
/**
|
|
38
|
-
* `initialRisk` is at or below the accepted floor (`<= minInitialRisk`,
|
|
39
|
-
* default `0`). Includes the zero-risk divide-by-zero case; no R is emitted
|
|
40
|
-
* rather than an infinite one.
|
|
41
|
-
*/
|
|
42
|
-
| "non-positive-risk"
|
|
43
|
-
/**
|
|
44
|
-
* `netRealizedPnl` or `initialRisk` is not a finite number, or the computed
|
|
45
|
-
* R-multiple overflowed to a non-finite value.
|
|
46
|
-
*/
|
|
47
|
-
| "non-finite"
|
|
48
|
-
/**
|
|
49
|
-
* A `cutoff` was supplied but the position's `resolutionTimestamp` is `null`
|
|
50
|
-
* or non-finite, so it cannot be placed relative to the cutoff.
|
|
51
|
-
*/
|
|
52
|
-
| "missing-timestamp"
|
|
53
|
-
/**
|
|
54
|
-
* A `cutoff` was supplied and `resolutionTimestamp > cutoff`: the outcome was
|
|
55
|
-
* not known by the cutoff, so including it would leak future information.
|
|
56
|
-
*/
|
|
57
|
-
| "after-cutoff";
|
|
58
|
-
/** Every exclusion reason, in a fixed order, for zero-filling tallies. */
|
|
59
|
-
export declare const R_MULTIPLE_EXCLUSION_REASONS: readonly RMultipleExclusionReason[];
|
|
60
|
-
/**
|
|
61
|
-
* One completed (fully realized) prediction-market position, already netted by
|
|
62
|
-
* the upstream impure adapter. The YES/NO distinction does not appear here: it
|
|
63
|
-
* is folded into the signed `netRealizedPnl` and the `initialRisk` before this
|
|
64
|
-
* function sees it.
|
|
65
|
-
*/
|
|
66
|
-
export interface ResolvedPosition {
|
|
67
|
-
/** Stable identifier, e.g. `${trader}:${conditionId}:${outcomeIndex}`. */
|
|
68
|
-
positionId: string;
|
|
69
|
-
/**
|
|
70
|
-
* Net realized profit or loss in USDC: sale proceeds + settlement redemptions
|
|
71
|
-
* minus entry cost minus fees. May be negative, or exactly `0` (break-even).
|
|
72
|
-
*/
|
|
73
|
-
netRealizedPnl: number;
|
|
74
|
-
/**
|
|
75
|
-
* Initial risk in USDC: the net premium paid to open the position. Must be
|
|
76
|
-
* strictly positive (and above `minInitialRisk`) to be usable as the R
|
|
77
|
-
* denominator.
|
|
78
|
-
*/
|
|
79
|
-
initialRisk: number;
|
|
80
|
-
/**
|
|
81
|
-
* Whether the position's P&L is fully realized — either the market settled at
|
|
82
|
-
* resolution or the position was fully exited early. Open positions
|
|
83
|
-
* (`false`) are never scored.
|
|
84
|
-
*/
|
|
85
|
-
resolved: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Epoch seconds at which the realized P&L became known (settlement time, or
|
|
88
|
-
* the final exit trade's time). Required (finite) for cutoff gating; `null`
|
|
89
|
-
* when the position is unresolved or the time is unknown.
|
|
90
|
-
*/
|
|
91
|
-
resolutionTimestamp: number | null;
|
|
92
|
-
}
|
|
93
|
-
/** A single dropped position and the reason it was dropped. */
|
|
94
|
-
export interface ExcludedPosition {
|
|
95
|
-
positionId: string;
|
|
96
|
-
/** The reason; never the implicit "included" state. */
|
|
97
|
-
reason: RMultipleExclusionReason;
|
|
98
|
-
}
|
|
99
|
-
/** Options for {@link rMultiplesFromResolvedPositions}. */
|
|
100
|
-
export interface RMultipleOptions {
|
|
101
|
-
/**
|
|
102
|
-
* Historical cutoff in epoch seconds. When supplied, only positions whose
|
|
103
|
-
* `resolutionTimestamp` is finite and `<= cutoff` are included; the rest are
|
|
104
|
-
* excluded as `after-cutoff` or `missing-timestamp`. Omitted means no gate.
|
|
105
|
-
*/
|
|
106
|
-
cutoff?: number;
|
|
107
|
-
/**
|
|
108
|
-
* Exclusive lower bound on `initialRisk` (USDC). A position is usable only
|
|
109
|
-
* when `initialRisk > minInitialRisk`. Defaults to `0`, so any strictly
|
|
110
|
-
* positive risk is accepted. Must be a finite, non-negative number.
|
|
111
|
-
*/
|
|
112
|
-
minInitialRisk?: number;
|
|
113
|
-
}
|
|
114
|
-
/** Result of {@link rMultiplesFromResolvedPositions}. */
|
|
115
|
-
export interface RMultipleConversion {
|
|
116
|
-
/**
|
|
117
|
-
* Finite R-multiples for the included positions, in the order they appeared
|
|
118
|
-
* in the input. Ready to pass straight to `computeForecasterTrustScore`.
|
|
119
|
-
*/
|
|
120
|
-
rMultiples: number[];
|
|
121
|
-
/** Number of included positions; always equals `rMultiples.length`. */
|
|
122
|
-
included: number;
|
|
123
|
-
/** One entry per dropped position, in input order, with its reason. */
|
|
124
|
-
excluded: ExcludedPosition[];
|
|
125
|
-
/**
|
|
126
|
-
* Count of exclusions per reason. Every {@link RMultipleExclusionReason} key
|
|
127
|
-
* is present and zero-filled, so callers can read any reason without a guard.
|
|
128
|
-
*/
|
|
129
|
-
excludedCounts: Record<RMultipleExclusionReason, number>;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Converts resolved prediction-market positions into per-position R-multiples,
|
|
133
|
-
* reporting every position that is dropped and why.
|
|
134
|
-
*
|
|
135
|
-
* Soft exclusions are evaluated in a fixed precedence; the first failing check
|
|
136
|
-
* wins, so each dropped position carries exactly one reason:
|
|
137
|
-
* 1. `unresolved` — `resolved === false`.
|
|
138
|
-
* 2. `missing-timestamp` — a `cutoff` is set but `resolutionTimestamp` is
|
|
139
|
-
* `null`/non-finite.
|
|
140
|
-
* 3. `after-cutoff` — a `cutoff` is set and `resolutionTimestamp > cutoff`.
|
|
141
|
-
* 4. `non-finite` (risk) — `initialRisk` is NaN or ±Infinity (checked before
|
|
142
|
-
* the threshold, so `+Infinity` cannot slip through).
|
|
143
|
-
* 5. `non-positive-risk` — finite `initialRisk <= minInitialRisk`.
|
|
144
|
-
* 6. `non-finite` (P&L) — `netRealizedPnl` is NaN or ±Infinity.
|
|
145
|
-
* 7. `non-finite` (R) — the finite division overflowed to a non-finite R.
|
|
146
|
-
*
|
|
147
|
-
* @param positions - Completed positions produced by the upstream adapter.
|
|
148
|
-
* @param options - See {@link RMultipleOptions}.
|
|
149
|
-
* @returns A {@link RMultipleConversion}: the finite R-multiples (input order),
|
|
150
|
-
* the included count, the excluded positions with reasons, and a zero-filled
|
|
151
|
-
* per-reason tally.
|
|
152
|
-
* @throws {TypeError} If `positions` is not an array, or any element is not a
|
|
153
|
-
* well-formed {@link ResolvedPosition} (missing/ wrong-typed `positionId`,
|
|
154
|
-
* `netRealizedPnl`, `initialRisk`, `resolved`, or `resolutionTimestamp`).
|
|
155
|
-
* @throws {RangeError} If `cutoff` is supplied and is not finite, or
|
|
156
|
-
* `minInitialRisk` is supplied and is not a finite, non-negative number.
|
|
157
|
-
*/
|
|
158
|
-
export declare function rMultiplesFromResolvedPositions(positions: readonly ResolvedPosition[], options?: RMultipleOptions): RMultipleConversion;
|
|
159
|
-
//# sourceMappingURL=r-multiple.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"r-multiple.d.ts","sourceRoot":"","sources":["../../../src/prediction/analysis/r-multiple.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,6EAA6E;AAC7E,MAAM,MAAM,wBAAwB;AAClC,2EAA2E;AACzE,YAAY;AACd;;;;GAIG;GACD,mBAAmB;AACrB;;;GAGG;GACD,YAAY;AACd;;;GAGG;GACD,mBAAmB;AACrB;;;GAGG;GACD,cAAc,CAAC;AAEnB,0EAA0E;AAC1E,eAAO,MAAM,4BAA4B,EAAE,SAAS,wBAAwB,EAM3E,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,+DAA+D;AAC/D,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,MAAM,EAAE,wBAAwB,CAAC;CAClC;AAED,2DAA2D;AAC3D,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;CAC1D;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,SAAS,gBAAgB,EAAE,EACtC,OAAO,GAAE,gBAAqB,GAC7B,mBAAmB,CA2GrB"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Forecaster Trust Score.
|
|
3
|
-
*
|
|
4
|
-
* A pure, deterministic implementation of the "Forecaster Trust Score"
|
|
5
|
-
* described in the AI Broker research paper
|
|
6
|
-
* (`apps/ai-broker-web/content/docs/agents/ai-broker-research-paper.md`, §3.2),
|
|
7
|
-
* which extends the per-trade Sharpe ratio with a sample-size confidence term so
|
|
8
|
-
* that a long, consistent track record is trusted more than a short, lucky one.
|
|
9
|
-
*
|
|
10
|
-
* Stated formula (paper §3.2):
|
|
11
|
-
*
|
|
12
|
-
* Trust = (meanR / stdR) * sqrt(N)
|
|
13
|
-
*
|
|
14
|
-
* where
|
|
15
|
-
* - meanR = mean R-multiple per resolved trade (edge per unit of risk),
|
|
16
|
-
* - stdR = standard deviation of R-multiples (consistency),
|
|
17
|
-
* - N = number of resolved trades (sample size).
|
|
18
|
-
*
|
|
19
|
-
* The leading `meanR / stdR` factor is the per-trade Sharpe ratio; `sqrt(N)` is
|
|
20
|
-
* the standard-error amplification that rewards larger samples. A forecaster
|
|
21
|
-
* with zero mean R-multiple scores zero regardless of N (paper §3.2.3), which is
|
|
22
|
-
* the no-edge baseline that distinguishes skill from luck.
|
|
23
|
-
*
|
|
24
|
-
* This module only computes the score. It deliberately does NOT read trades from
|
|
25
|
-
* a database or API, resolve markets, size positions, or place orders — it is a
|
|
26
|
-
* self-contained numeric function with no network, no clock, and no execution
|
|
27
|
-
* side effects, so it can be unit-tested and reasoned about in isolation.
|
|
28
|
-
*
|
|
29
|
-
* NOTE ON THE PAPER'S WORKED TABLE: the example table in §3.2 (forecasters
|
|
30
|
-
* P1–P10) is internally inconsistent for three rows. P5, P6 and P7 print a
|
|
31
|
-
* `Trust` value that disagrees with the paper's own `Sharpe` column and with the
|
|
32
|
-
* stated formula `Sharpe * sqrt(N)` (e.g. P7: 0.46 * sqrt(120) = 5.07, not the
|
|
33
|
-
* printed 4.00). The other seven rows agree with the formula to within rounding.
|
|
34
|
-
* This implementation follows the stated formula; the test file documents each
|
|
35
|
-
* discrepancy explicitly.
|
|
36
|
-
*/
|
|
37
|
-
/** Why a score is (or is not) reliable. See {@link ForecasterTrustScore}. */
|
|
38
|
-
export type TrustScoreReason =
|
|
39
|
-
/** Score computed and sample size meets the minimum — safe to rely on. */
|
|
40
|
-
"ok"
|
|
41
|
-
/** No trades supplied; nothing to score. */
|
|
42
|
-
| "empty"
|
|
43
|
-
/** Score computed, but fewer than `minSampleSize` trades — treat as weak. */
|
|
44
|
-
| "insufficient-sample"
|
|
45
|
-
/**
|
|
46
|
-
* R-multiples have zero dispersion while the mean is non-zero, so the
|
|
47
|
-
* Sharpe ratio (and therefore the score) is undefined rather than infinite.
|
|
48
|
-
*/
|
|
49
|
-
| "zero-variance"
|
|
50
|
-
/**
|
|
51
|
-
* R-multiples have zero dispersion AND a zero mean (every trade identical,
|
|
52
|
-
* e.g. an all-zero / all-break-even history). There is no edge and no spread
|
|
53
|
-
* to measure, so this carries no information — not a reliable zero.
|
|
54
|
-
*/
|
|
55
|
-
| "no-information"
|
|
56
|
-
/**
|
|
57
|
-
* Inputs were individually finite but their sum or dispersion overflowed to
|
|
58
|
-
* a non-finite value, so no finite score exists.
|
|
59
|
-
*/
|
|
60
|
-
| "overflow";
|
|
61
|
-
/** Options for {@link computeForecasterTrustScore}. */
|
|
62
|
-
export interface ForecasterTrustScoreOptions {
|
|
63
|
-
/**
|
|
64
|
-
* Minimum number of resolved trades for a score to be considered reliable.
|
|
65
|
-
* Defaults to 25, matching the `N >= 25` threshold used throughout the paper.
|
|
66
|
-
* A score is still computed below this, but is flagged `reliable: false`.
|
|
67
|
-
*/
|
|
68
|
-
minSampleSize?: number;
|
|
69
|
-
/**
|
|
70
|
-
* Delta degrees of freedom for the standard deviation of R-multiples:
|
|
71
|
-
* - `1` (default): sample standard deviation (divides the sum of squared
|
|
72
|
-
* deviations by `N - 1`), matching the finance Sharpe-ratio convention the
|
|
73
|
-
* paper's Sharpe column is built on.
|
|
74
|
-
* - `0`: population standard deviation (divides by `N`).
|
|
75
|
-
* With a single trade (`N - ddof <= 0`) the dispersion is not estimable and is
|
|
76
|
-
* treated as zero variance.
|
|
77
|
-
*/
|
|
78
|
-
ddof?: 0 | 1;
|
|
79
|
-
}
|
|
80
|
-
/** Result of {@link computeForecasterTrustScore}. */
|
|
81
|
-
export interface ForecasterTrustScore {
|
|
82
|
-
/**
|
|
83
|
-
* The Trust Score `(meanR / stdR) * sqrt(N)`, or `null` when it is not finitely
|
|
84
|
-
* defined (no trades, zero dispersion, or overflow). Never `NaN` or `Infinity`.
|
|
85
|
-
*/
|
|
86
|
-
score: number | null;
|
|
87
|
-
/**
|
|
88
|
-
* Whether `score` is a finite number — i.e. the formula is mathematically
|
|
89
|
-
* defined for this input. Independent of sample size. Equivalent to
|
|
90
|
-
* `score !== null`.
|
|
91
|
-
*/
|
|
92
|
-
isDefined: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Whether `sampleSize >= minSampleSize` — i.e. there is enough evidence to
|
|
95
|
-
* trust the number. Independent of whether the score is defined.
|
|
96
|
-
*/
|
|
97
|
-
hasSufficientSample: boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Safe to act on: `isDefined && hasSufficientSample`. A single flag for the
|
|
100
|
-
* common "should I use this?" check; inspect `isDefined` / `hasSufficientSample`
|
|
101
|
-
* (or `reason`) to see which condition failed.
|
|
102
|
-
*/
|
|
103
|
-
reliable: boolean;
|
|
104
|
-
/** Number of resolved trades used (array length). */
|
|
105
|
-
sampleSize: number;
|
|
106
|
-
/** Mean R-multiple. `0` when there are no trades. */
|
|
107
|
-
meanR: number;
|
|
108
|
-
/** Standard deviation of R-multiples under `ddof`. `0` when undefined. */
|
|
109
|
-
stdR: number;
|
|
110
|
-
/** Per-trade Sharpe ratio `meanR / stdR`, or `null` when `stdR` is `0`. */
|
|
111
|
-
sharpe: number | null;
|
|
112
|
-
/** Machine-readable explanation of `score` / `reliable`. */
|
|
113
|
-
reason: TrustScoreReason;
|
|
114
|
-
/** The effective minimum sample size used for the reliability decision. */
|
|
115
|
-
minSampleSize: number;
|
|
116
|
-
}
|
|
117
|
-
/** Default minimum resolved-trade count for a reliable score (paper: N >= 25). */
|
|
118
|
-
export declare const DEFAULT_MIN_SAMPLE_SIZE = 25;
|
|
119
|
-
/**
|
|
120
|
-
* Computes the Trust Score directly from pre-aggregated moments.
|
|
121
|
-
*
|
|
122
|
-
* This is the exact formula `(meanR / stdR) * sqrt(sampleSize)` with safe
|
|
123
|
-
* handling of the degenerate cases, kept separate from
|
|
124
|
-
* {@link computeForecasterTrustScore} so callers that already have summary
|
|
125
|
-
* statistics (for example, the paper's worked table) can use it without
|
|
126
|
-
* reconstructing a per-trade array.
|
|
127
|
-
*
|
|
128
|
-
* @param meanR - Mean R-multiple.
|
|
129
|
-
* @param stdR - Standard deviation of R-multiples (must be `>= 0`).
|
|
130
|
-
* @param sampleSize - Number of resolved trades (non-negative integer).
|
|
131
|
-
* @returns The finite Trust Score, or `null` when it is undefined: no trades
|
|
132
|
-
* (`sampleSize === 0`) or zero dispersion (`stdR === 0`, including a zero mean
|
|
133
|
-
* — the t-statistic needs non-zero sample variance). A zero mean with POSITIVE
|
|
134
|
-
* variance scores `0` (no edge), per the paper. Never `NaN`/`Infinity`.
|
|
135
|
-
* @throws {TypeError} If any argument is not a finite number.
|
|
136
|
-
* @throws {RangeError} If `sampleSize` is negative or non-integer, or `stdR < 0`.
|
|
137
|
-
*/
|
|
138
|
-
export declare function trustScoreFromMoments(meanR: number, stdR: number, sampleSize: number): number | null;
|
|
139
|
-
/**
|
|
140
|
-
* Computes a {@link ForecasterTrustScore} from a forecaster's resolved-trade
|
|
141
|
-
* R-multiples.
|
|
142
|
-
*
|
|
143
|
-
* Each element is one resolved trade's R-multiple (profit or loss expressed in
|
|
144
|
-
* units of the risk taken on that trade). The caller is responsible for turning
|
|
145
|
-
* raw trade history into R-multiples; this function performs no resolution,
|
|
146
|
-
* I/O, or time-dependent work.
|
|
147
|
-
*
|
|
148
|
-
* @param rMultiples - Finite R-multiples, one per resolved trade.
|
|
149
|
-
* @param options - See {@link ForecasterTrustScoreOptions}.
|
|
150
|
-
* @returns A fully populated {@link ForecasterTrustScore}. Insufficient evidence
|
|
151
|
-
* is reported via `reliable`/`reason`, never hidden behind a bare number.
|
|
152
|
-
* @throws {TypeError} If `rMultiples` is not an array or contains a non-finite
|
|
153
|
-
* value.
|
|
154
|
-
* @throws {RangeError} If `minSampleSize` is not a positive integer, or `ddof`
|
|
155
|
-
* is not `0` or `1`.
|
|
156
|
-
*/
|
|
157
|
-
export declare function computeForecasterTrustScore(rMultiples: readonly number[], options?: ForecasterTrustScoreOptions): ForecasterTrustScore;
|
|
158
|
-
//# sourceMappingURL=trust-score.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trust-score.d.ts","sourceRoot":"","sources":["../../../src/prediction/analysis/trust-score.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,6EAA6E;AAC7E,MAAM,MAAM,gBAAgB;AAC1B,0EAA0E;AACxE,IAAI;AACN,4CAA4C;GAC1C,OAAO;AACT,6EAA6E;GAC3E,qBAAqB;AACvB;;;GAGG;GACD,eAAe;AACjB;;;;GAIG;GACD,gBAAgB;AAClB;;;GAGG;GACD,UAAU,CAAC;AAEf,uDAAuD;AACvD,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CACd;AAED,qDAAqD;AACrD,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,4DAA4D;IAC5D,MAAM,EAAE,gBAAgB,CAAC;IACzB,2EAA2E;IAC3E,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAqBf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,OAAO,GAAE,2BAAgC,GACxC,oBAAoB,CAuFtB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Refill size limits, kept apart from refill.ts so callers that only validate
|
|
3
|
-
* input (route handlers, tests) do not import the database client.
|
|
4
|
-
*/
|
|
5
|
-
/** Upper bound an admin refill may request, so one click cannot run all night. */
|
|
6
|
-
export declare const MAX_REFILL_MARKETS = 5000;
|
|
7
|
-
/** Clamps a requested refill size to 1…MAX_REFILL_MARKETS (0 or junk → default). */
|
|
8
|
-
export declare function clampRefillSize(value: unknown, fallback?: number): number;
|
|
9
|
-
//# sourceMappingURL=refill-limits.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"refill-limits.d.ts","sourceRoot":"","sources":["../../../src/prediction/sync/refill-limits.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kFAAkF;AAClF,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,SAAM,GAAG,MAAM,CAItE"}
|