|
PineForge HPO 1.11.0
Native hyperparameter optimization for PineForge strategies
|
Classes | |
| class | DsrError |
Functions | |
| dict | dsr (Any source, *str series, int selected, int|None n_trials=None, int|None max_work=None) |
Variables | |
| str | CONTRACT = "pineforge-hpo-dsr/v1" |
| str | ALGORITHM = "deflated_sharpe_exact_v1" |
| tuple | CODES |
| tuple | INTERPRETATION |
Deflated Sharpe ratio of one selected trial from a finished study. ``dsr`` reads one complete result, rows JSONL file, parsed result dictionary or list of rows through the shared reader. The caller must name ``series`` (``bar`` or ``monthly``) and ``selected`` (a trial id); neither has a default. This library function runs no trial, writes no file, keeps no state and changes no native result. Contract ``pineforge-hpo-dsr/v1``, algorithm ``deflated_sharpe_exact_v1`` uses the selected row's recorded excess ``sharpe_per_period``, ``count``, population skewness and raw population kurtosis (normal = 3). It never reads the objective as a Sharpe, annualises a ratio, or converts the recorded moment conventions. Only ``ok`` rows with all five requested return-statistic keys, a series status that is exactly the integer zero, finite numeric values and an integer count in 2..2^53 are eligible. The first exclusion reason decides: ``status_<status>``, ``returns_not_recorded``, ``returns_status_nonzero``, then ``returns_unavailable``. Eligible rows alone feed the sample variance and the selected row's statistics. Default N counts every row read, including excluded trials and warm-start ancestors: this is the conservative choice because every recorded trial was still searched. A caller's ``n_trials`` must be an integer in 2..2^50 and at least the rows read. Before exclusions, a requested series entry of any row that cannot be written as key-sorted JSON refuses the call as ``dsr_input_invalid``. An object whose keys cannot be sorted in any of the five entries also refuses. Its ``ids`` is the union of the offending trial ids in ascending order, and ``names`` lists the offending entry keys in ascending alphabetical order. An ``ok`` row with all five keys, series status zero and an integer value whose float conversion overflows is excluded as ``returns_unavailable``. An integer beyond the interpreter's integer-to-text limit in a value entry is not refused: its digest cell is ``["other", "<unwritable>"]``. An integer beyond the interpreter's integer-to-text limit in the status entry is refused so the result's ``statuses`` can be written; a smaller large integer there is a status that is not ok. The sample variance V and the denominator ``1 - g3*SR + ((g4-1)/4)*SR^2`` are exact rationals over the binary64 inputs, each rounded once, ties to even. Both must be positive as rationals and after rounding. The same rounded denominator is reported and used for its square root. The remaining scalar binary64 operations follow a fixed order: float(N); division then subtraction for ``1 - 1/N``; multiplication, division then subtraction for ``1 - 1/(N*E)``; the two inverse normal calls; the weighted sum; sqrt(V) times that sum; sqrt(float(T)-1); sqrt(den); subtraction, multiplication then division for z; the normal cdf. G is 0.5772156649015329 and E is 2.718281828459045. Phi and its inverse come from ``statistics.NormalDist``. Every intermediate must be finite; a finite z whose cdf saturates to 0.0 or 1.0 is valid. The returned document names every eligible and excluded id in ascending order, with ascending reason keys and distinct nonzero series statuses ordered by integer value first, then compact JSON text. Its SHA-256 covers every row read through sorted per-row digests of the id, status and five typed return-statistic cells; it covers neither the selection nor N. Absent and null cells coincide, while integers, floats and booleans retain distinct representations. The admission figure is rows read + eligible rows, with no built-in cap. A refusal raises ``DsrError``; ``document()`` renders only the refusal. The first defect decides: parameters (series, selected, n_trials, max_work); source, context and series cells; eligible count (zero before one); selection (unknown before excluded); N against rows read; admission figure; variance then the remaining statistic. Under the paper's assumptions the DSR reads as the probability that the selected trial's true Sharpe exceeds the expected maximum of N unskilled trials. Tuned trials are correlated, so this is a deflated reading under a stated N, not a significance test. Recorded data is taken as given, no threshold is applied and no out-of-sample performance is claimed. v1 analyses finished studies; native in-loop walk-forward comes later.
| dict pineforge_hpo.dsr.dsr | ( | Any | source, |
| *str | series, | ||
| int | selected, | ||
| int | None | n_trials = None, |
||
| int | None | max_work = None |
||
| ) |
| tuple pineforge_hpo.dsr.CODES |
| tuple pineforge_hpo.dsr.INTERPRETATION |