Sizing: no financing floor when a trade costs nothing (zero commission and spread)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-09-26 18:46:04 -05:00
co-authored by Claude Opus 5.5
parent 169fe19fad
commit 957b9a50fe
+3 -1
View File
@@ -1431,7 +1431,9 @@ export function sizeNotional(o: {
for (let pass = 0; pass < 4; pass++) { for (let pass = 0; pass < 4; pass++) {
const { a, b } = distances(n); const { a, b } = distances(n);
const nTime = Math.sqrt((a * b) / (sigma * sigma * hold)); const nTime = Math.sqrt((a * b) / (sigma * sigma * hold));
const nCost = fh > 0 ? Math.sqrt((fh * a * b) / (sigma * sigma * (2 * c + s))) : 0; // No per-trade cost (a zero-commission firm on a zero spread): no
// floor — there is nothing for a bigger position to save.
const nCost = fh > 0 && 2 * c + s > 0 ? Math.sqrt((fh * a * b) / (sigma * sigma * (2 * c + s))) : 0;
n = Math.max(nTime, nCost); n = Math.max(nTime, nCost);
} }
if (!Number.isFinite(n) || n <= 0) return null; if (!Number.isFinite(n) || n <= 0) return null;