-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
203 lines (183 loc) · 5.27 KB
/
Copy pathindex.ts
File metadata and controls
203 lines (183 loc) · 5.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/**
* Public API surface for @kiploks/engine-contracts.
* Keep these exports stable across minor releases.
*/
export const ENGINE_VERSION = "0.4.3";
export const ANALYSIS_ENGINE_VERSION = "3.0";
export const FORMULA_VERSION = "2.2.0";
export const RISK_ANALYSIS_VERSION = 1;
export const CONTRACT_VERSION = "1.0.0";
export const DEFAULT_DECIMALS = 8;
export {
WFE_PERMUTATION_N_DEFAULT,
WFE_PERMUTATION_N_MIN,
WFE_PERMUTATION_N_MAX,
WFE_PERMUTATION_P_WEAK_THRESHOLD,
} from "./wfePermutation";
export type CanonicalScaledNumber = {
v: string;
scale: number;
};
export type {
TradeInput,
Trade,
AnalyzeInput,
AnalysisSummary,
ReproducibilityMetadata,
AnalyzeOutput,
AnalyzeConfig,
} from "./analyzeContract";
export type {
KiploksErrorCode,
KiploksUnavailableReason,
KiploksWarningCode,
BlockResult,
KiploksWarning,
} from "./errors";
export { KiploksValidationError } from "./errors";
export type {
EquityPoint,
WindowConfig,
WindowMetrics,
WFAWindow,
TradeBasedWFAInput,
PrecomputedWFAInput,
WFEResult,
ConsistencyResult,
ParameterStabilityResult,
BenchmarkResult,
NarrativeResult,
DQGResult,
KillSwitchResult,
WFAAnalysisOutput,
} from "./wfaAnalysisContract";
export { WFA_PUBLIC_ANALYSIS_SCHEMA_VERSION } from "./wfaAnalysisContract";
// --- Robustness Score from WFA (open core candidate) ---
export type RobustnessBlockedByModule = "validation" | "risk" | "stability" | "execution";
export type RobustnessScoreFromWfaInput = {
backtestResult?: { results?: Record<string, unknown> } | null;
walkForwardAnalysis:
| {
stabilityScore?: number | null;
wfe?: number | null;
consistency?: number | null;
overfittingScore?: number | null;
periods?: Array<{
optimizationReturn?: number;
validationReturn?: number;
}>;
performanceTransfer?: {
windows?: Array<{
oosEquityCurve?: Array<{ date?: string; value?: number; equity?: number }>;
}>;
};
failedWindows?: { count?: number; total?: number };
}
| null
| undefined;
monteCarloAnalysis?: unknown;
proBenchmarkMetrics?: Record<string, unknown> | null;
riskAnalysis?: Record<string, unknown> | null;
parameterSensitivity?: Record<string, unknown> | null;
turnoverAndCostDrag?: Record<string, unknown> | null;
};
export type RobustnessScoreFromWfaResult = {
overall: number;
potentialOverall?: number;
components: {
parameterStability: number;
timeRobustness: number;
marketRegime: number;
monteCarloStability: number;
sensitivity: number;
dataQuality?: number;
};
modules: {
validation: number;
risk: number;
stability: number;
execution: number;
};
blockedByModule?: RobustnessBlockedByModule;
blockedByModules?: RobustnessBlockedByModule[];
wfeNote?: string;
stabilityNotComputed?: boolean;
};
// --- Walk Forward Analysis: Professional WFA (open core candidate) ---
export type WfaProfessionalCurvePointInput = {
date?: string;
timestamp?: number | string;
t?: number | string;
value?: number;
balance?: number;
equity?: number;
};
export type WfaProfessionalPerformanceTransferWindowInput = {
oosEquityCurve?: WfaProfessionalCurvePointInput[];
equityCurve?: WfaProfessionalCurvePointInput[];
curve?: WfaProfessionalCurvePointInput[];
};
export type WfaProfessionalPerformanceTransferInput = {
windows?: WfaProfessionalPerformanceTransferWindowInput[];
};
export type WfaProfessionalPeriodInput = {
optimizationReturn?: number;
validationReturn?: number;
optimization_return?: number;
validation_return?: number;
parameters?: Record<string, number>;
params?: Record<string, number>;
optimization_params?: Record<string, number>;
optimized_params?: Record<string, number>;
validationMaxDD?: number;
metrics?: {
optimization?: { totalReturn?: number; total?: number };
validation?: { totalReturn?: number; total?: number };
};
};
export type WfaProfessionalInput = {
periods?: WfaProfessionalPeriodInput[];
windows?: WfaProfessionalPeriodInput[];
performanceTransfer?: WfaProfessionalPerformanceTransferInput;
/** Integration WFA verdict; used with `failedWindows` for submit-time grade guard. */
verdict?: string;
failedWindows?: { count?: number; total?: number };
};
export type WfaProfessionalOptions = {
seed?: number;
permutationN?: number;
bootstrapN?: number;
monteCarloMode?: "legacy" | "auto" | "new_only";
enablePathMc?: boolean;
pathSimulations?: number;
maxEquityPoints?: number;
cpuBudgetMs?: number;
};
export type {
InstitutionalGradeOverride,
InstitutionalGradeOverrideCode,
} from "./institutionalGradeOverride";
export type {
DistributionStats,
MonteCarloPercentileSet,
PathMonteCarloBlock,
PathMonteCarloEquityPoint,
PathMonteCarloMeta,
PathMonteCarloOptions,
PathMonteCarloResult,
PathStability,
TailRisk,
} from "./pathMonteCarlo";
export type { IntegrationPayloadRaw, UnifiedIntegrationPayload } from "./unifiedPayload";
export type {
RobustnessScoreTextPayload,
RobustnessScore,
WalkForwardAnalysisTextPayload,
ProfessionalMonteCarloMethod,
ProfessionalMonteCarloReasonCode,
ProfessionalMonteCarloValidation,
ProfessionalWfa,
ProfessionalMeta,
WalkForwardAnalysis,
TestResultData,
} from "./testResultData";