Commit 7e93913
committed
Return nan from deflated_sharpe_ratio for returns with no dispersion
An equity curve growing at a constant rate has no Sharpe ratio, but it does not
reach the deflation arithmetic as a nan. The standard deviation of its returns
is floating-point residue rather than an exact zero, so it divides out to a
Sharpe of ~1e13 -- finite, and therefore past the existing check. Deflating that
returned 1.0: certainty of a real edge, from the one input that carries no
information about one.
These returns are ratios of floats, so the residue is of the order of an ulp of
1.0 rather than of the returns' own magnitude. Measured at 0.44-0.61 eps across
constant rates from -1% to +5% and lengths 50-3000, against 4e7 eps for a real
series with sigma=1e-8, so one eps separates them with seven orders of magnitude
to spare. The test was run against the unfixed function and fails there, so it
tests the guard rather than accompanying it.1 parent cd7e7ab commit 7e93913
2 files changed
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
267 | 279 | | |
268 | 280 | | |
269 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1010 | 1010 | | |
1011 | 1011 | | |
1012 | 1012 | | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
1013 | 1035 | | |
1014 | 1036 | | |
1015 | 1037 | | |
| |||
0 commit comments