Deflated Sharpe Ratio: synthetic, known-answer teaching package Formula version: Bailey and Lopez de Prado (2014), equation 2. This is NOT the EdgeVeris production engine, market data or customer research. FILES AND RUNNING Save reproduce.py, fixture.json and expected.json in the same directory. Also save search-context.svg and eligibility.svg for the full --check command. Python 3.10+ standard library only, no package installation or network access. python3 -B reproduce.py --check python3 -B test_reproduce.py python3 -B reproduce.py The last command prints the recomputed output. Tests also need test_reproduce.py. Generate fresh fixture/output/figures without overwriting existing files: python3 -B reproduce.py --write my-dsr-output INPUTS fixture.json contains four complete selected return samples (decimal net excess returns per artificial daily observation), four complete candidate-Sharpe summary ledgers and eight case declarations. A zero risk-free reference is stipulated. These are summaries, not the complete joint return history of all candidates. They cannot establish independence or estimate candidate-return correlations. All candidate values, including every unselected value, are disclosed. The 10/50/100 cases use the IDENTICAL selected 252-observation sample and SR=.15. The native-frequency Sharpe is mean / sample SD (ddof=1). Cross-trial variance is measured from each entire ledger (ddof=1). Skewness is m3/m2^(3/2), Pearson kurtosis is m4/m2^2. Each central moment mk uses divisor T. These are biased standardized central moments, not corrected sample skewness/kurtosis. The current product's pandas corrected-moment convention differs. Do not compare the two implementations without harmonizing inputs, sampling and moment estimators. Construction: deterministic normal mid-quantiles, optionally one negative-tail shock, centered/rescaled to a target mean/sample SD, then fixed permutation. The full ordered return arrays and every trial summary are in fixture.json. These hand-built observations are NOT independent empirical draws and do not validate the statistical calibration of the model. They expose arithmetic only. The moderate case has 1260 observations and SR=.10. The short case has 20. The tail case has 252 and SR=.15 with skew about -5.168 and kurtosis about 58.562. MODEL ASSUMPTIONS The formula's independent-trial count and approximately normal distribution of trial Sharpe estimates under the null are stipulated for the numeric examples. The trial-null mean is zero. The benchmark is the original expected-maximum approximation, using empirical dispersion of each supplied summary ledger. Euler gamma=.5772156649015329. Phi is the standard normal CDF. benchmark = sd(SR_trials) * [(1-gamma)*Phi^-1(1-1/N) + gamma*Phi^-1(1-1/(N*e))] z = (selected_SR - benchmark)*sqrt(T-1) /sqrt(1 - skew*selected_SR + (Pearson_kurtosis-1)*selected_SR^2/4) conditional_DSR = Phi(z) All Sharpes use native observation frequency. The displayed annualized number uses sqrt(252) but is never substituted into the daily-frequency formula. The exact selected sample, T, skew and kurtosis do not change across 10/50/100. Both N and the measured cross-trial dispersion change across those ledgers. The separate countOnlySensitivity holds SD fixed at the 10-trial value and varies ASSUMED N. It is a conditional illustration, not missing observed trial history. KNOWN ANSWERS (full precision in expected.json) N10: benchmark .127586733553, DSR .638028398283 N50: benchmark .173580733273, DSR .355098708863 N100: benchmark .191471777873, DSR .256709769547 All three PSR versus zero: .990954167245. Moderate case DSR: .988466863565. Short case DSR: .538750382178. Tail case DSR: .596809234610. Missing history and unknown trial-dependence model: not_enough_evidence, no score. Independent published control: the 2014 paper's numerical example has annual SR 2.5, annual cross-trial SR variance .5, 250 observations/year, T1250, skew -3 and Pearson kurtosis10. Converted to native frequency, N100 gives .900396834449 (paper .9004) and N46 gives .950501706876 (paper .9505). ELIGIBILITY AND LIMITS The paper motivates the expected-maximum approximation for large N. Evaluating it at N>=2 is a numerical input rule, not evidence of small-N accuracy. The N=2/5 sensitivity rows are conditional arithmetic, not exact small-search maxima. Finite returns, positive return variance and positive cross-trial dispersion are required. The unique maximum-Sharpe selection rule is fixed in this small demo. Duplicate IDs, a tied winner or mismatched selected SR are rejected rather than silently interpreted. The runner verifies raw standardized moments against Pearson's inequality and requires a positive variance adjustment. N=1 is outside this expected-maximum approximation as implemented. A single pre-specified candidate can use a declared PSR benchmark but does not provide a selection-dispersion estimate. Never replace an unknown trial count with one. Four observations is a runner input bound, NOT evidence that DSR is reliable with four observations. Short and extreme-tail examples are numerical controls, not recommendations to trust estimated moments in those settings. No serial-correlation / long-run-autocovariance correction is made. More simulated paths are not more historical observations. A finite numerical score does not establish the assumptions, trial independence, clean OOS, execution feasibility, future profit, causal economic edge or regime persistence. No pass/fail threshold or investment decision is prescribed. Model scores are not posterior odds that a strategy is genuine, profitable or not overfit. PRIMARY SOURCES Bailey and Lopez de Prado (2014), The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting, and Non-Normality, Journal of Portfolio Management40(5),94-107. Equations1-2 and numerical example. https://www.davidhbailey.com/dhbpapers/deflated-sharpe.pdf Bailey and Lopez de Prado (2012), The Sharpe Ratio Efficient Frontier, Journal of Risk15(2),3-44. Equation11 (PSR). https://www.davidhbailey.com/dhbpapers/sharpe-frontier.pdf