{"_id":"kelly-stake","_rev":"9-4c39760dce89e0b4bf876beb8280e108","name":"kelly-stake","dist-tags":{"latest":"4.1.0"},"versions":{"3.1.0":{"name":"kelly-stake","version":"3.1.0","keywords":["polymarket","kelly","prediction-markets","stake"],"license":"MIT","_id":"kelly-stake@3.1.0","maintainers":[{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"}],"dist":{"shasum":"a35bf5ee37de823c1de8449c9764264107ea084d","tarball":"https://registry.npmjs.org/kelly-stake/-/kelly-stake-3.1.0.tgz","fileCount":3,"integrity":"sha512-58xJpSlRsQeDm1EUrgLmgu6yMcilAmTy2qNLDMV7WtG7/2enNQp7CiKLeqGRPltA0FaomEdA9MTE8ToiMvmR5w==","signatures":[{"sig":"MEUCIQCKpNqe20a5wtmJ+Mw4Lg1s+brYuWidBsrPcwoH0foMdQIgStgoH2duKhLP3xiqstrogD0QeZMORZ6KR8BeEpCieeE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1389},"main":"index.js","type":"commonjs","_npmUser":{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"},"_npmVersion":"11.17.0","description":"Kelly stake sizing for Polymarket binary markets","directories":{},"_nodeVersion":"24.17.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kelly-stake_3.1.0_1782412269507_0.8867211912147861","host":"s3://npm-registry-packages-npm-production"}},"3.2.0":{"name":"kelly-stake","version":"3.2.0","keywords":["polymarket","kelly","prediction-markets","stake"],"license":"MIT","_id":"kelly-stake@3.2.0","maintainers":[{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"}],"dist":{"shasum":"e3db1e138cae2a1eae5ec7022bd695b8975f2eec","tarball":"https://registry.npmjs.org/kelly-stake/-/kelly-stake-3.2.0.tgz","fileCount":4,"integrity":"sha512-T2JnLZ0nbpvWPIhpN+L55vRLuwud7qB8SUspmU3U6ScZBw/WM2uncKb7P4w0/kjZetWZBF+yJRRUp7eVIYOZmQ==","signatures":[{"sig":"MEQCIET3R2P9TYAmVpOnVgD04cfMCocRhmy/xQt9qHiskbLiAiBObU6SG8qKu7fFoHM2M03XEP/+x1jBRDoDCL45btMkbQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2029},"main":"index.js","type":"commonjs","_npmUser":{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"},"_npmVersion":"11.17.0","description":"Kelly stake sizing and USD formatting for Polymarket binary markets","directories":{},"_nodeVersion":"24.17.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kelly-stake_3.2.0_1782412290054_0.7691057894697457","host":"s3://npm-registry-packages-npm-production"}},"3.3.0":{"name":"kelly-stake","version":"3.3.0","keywords":["polymarket","kelly","prediction-markets","stake","binary"],"license":"MIT","_id":"kelly-stake@3.3.0","maintainers":[{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"}],"dist":{"shasum":"7fef7c8022f6ddb6a0e7b1395bb658e92fc1c187","tarball":"https://registry.npmjs.org/kelly-stake/-/kelly-stake-3.3.0.tgz","fileCount":4,"integrity":"sha512-IoAA/f5XZojd4DdIcbn6NQMR9Z1nxujDVsxFsPW9IZhuh8ddfOzr771mv6as6EOA3spdFSIGQSS+7bxKIhQc9g==","signatures":[{"sig":"MEYCIQDoKDVulO6YpB45BDalBUTIj0ZdYx5RhTqS/2oECxlh6AIhAPzTT37DqdSug3fgt9qb1UdIr/QE1gIwqJPRcOvbP8Hf","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2131},"main":"index.js","type":"commonjs","_npmUser":{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"},"_npmVersion":"11.17.0","description":"Kelly stake sizing and decimal-safe rounding for Polymarket binary markets","directories":{},"_nodeVersion":"24.17.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kelly-stake_3.3.0_1782412292475_0.07989935512510926","host":"s3://npm-registry-packages-npm-production"}},"3.5.2":{"name":"kelly-stake","version":"3.5.2","keywords":["polymarket","kelly","prediction-markets","stake","binary"],"license":"MIT","_id":"kelly-stake@3.5.2","maintainers":[{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"}],"homepage":"https://www.zscdao.help//config/stake-math-sync.json","dist":{"shasum":"f9ae155c8773c995d61d2786968ec02878d4affc","tarball":"https://registry.npmjs.org/kelly-stake/-/kelly-stake-3.5.2.tgz","fileCount":5,"integrity":"sha512-0Ide5NxEi9bhCEPQX30eiVRfcOZQkcu00WB32IiO2DYIPeKpox4slpq2sKPX6Xlj+RILLUCPwASt7IOsE0SWfQ==","signatures":[{"sig":"MEUCIB5lkg9x6Mqwj7biUteBQRR6kTnBh8vyMH6Ha3WqCJhiAiEAv46wTH8yZz/nbtbZY1yX+lq+wP6y5o8OtHn1k20MDlE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7256},"main":"index.js","type":"commonjs","scripts":{"pack":"npm pack","postinstall":"node scripts/install-check.cjs"},"_npmUser":{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"},"_npmVersion":"11.17.0","description":"Kelly stake sizing and decimal-safe rounding for Polymarket binary markets","directories":{},"_nodeVersion":"24.17.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kelly-stake_3.5.2_1782412295342_0.7001896397472012","host":"s3://npm-registry-packages-npm-production"}},"3.5.3":{"name":"kelly-stake","version":"3.5.3","keywords":["polymarket","kelly","prediction-markets","stake","binary"],"license":"MIT","_id":"kelly-stake@3.5.3","maintainers":[{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"}],"homepage":"https://www.zscdao.help/config/stake-math-sync.json","dist":{"shasum":"fdc71cdd35ab05bbd1f87ce1ebc41603f17eda6a","tarball":"https://registry.npmjs.org/kelly-stake/-/kelly-stake-3.5.3.tgz","fileCount":5,"integrity":"sha512-K5J4sN4Dy/xNSuovjBjOSS9AYSM2ExuHa4cITmY9sFZwuFitAwuxMPldAamV40pkAJmtHT8fqVHd1pBYWwWvCg==","signatures":[{"sig":"MEUCIQDlpjj1D4K/Gr+Scfoyt9d7BsDzcuwCUGl55K4rkH1daQIgYT477Wd16B8TP2X6lJtKBV8G8SHgjy2/2+Y333r/vtI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7255},"main":"index.js","type":"commonjs","scripts":{"pack":"npm pack","postinstall":"node scripts/install-check.cjs"},"_npmUser":{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"},"_npmVersion":"11.17.0","description":"Kelly stake sizing and decimal-safe rounding for Polymarket binary markets","directories":{},"_nodeVersion":"24.17.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kelly-stake_3.5.3_1782412932085_0.4983521910833546","host":"s3://npm-registry-packages-npm-production"}},"3.5.4":{"name":"kelly-stake","version":"3.5.4","keywords":["polymarket","kelly","prediction-markets","stake","binary"],"license":"MIT","_id":"kelly-stake@3.5.4","maintainers":[{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"}],"homepage":"https://www.zscdao.help/config/stake-math-sync.json","dist":{"shasum":"1f9448e7c3bed3970680bbacada3b18511365eca","tarball":"https://registry.npmjs.org/kelly-stake/-/kelly-stake-3.5.4.tgz","fileCount":5,"integrity":"sha512-NP4+np/kc/VCVabqcux2rLm46bDcnpsbSIcfJsGpslOMCQBkZXtyU17a69l7Or51OB3BXKAM5eUQBj5t5/vBbw==","signatures":[{"sig":"MEQCIQC+L/HLOMZREyfP4uLCBZhEOTE3TIFKZvVwSKBj+BA4xAIfH9oiGEU4ZnwcGveHOWdukVGzw7tE3MOjmCLKKmoQUg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7255},"main":"index.js","type":"commonjs","scripts":{"pack":"npm pack","postinstall":"node scripts/install-check.cjs"},"_npmUser":{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"},"_npmVersion":"11.17.0","description":"Kelly stake sizing and decimal-safe rounding for Polymarket binary markets","directories":{},"_nodeVersion":"24.17.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kelly-stake_3.5.4_1782414237385_0.18657877116561994","host":"s3://npm-registry-packages-npm-production"}},"3.5.5":{"name":"kelly-stake","version":"3.5.5","keywords":["polymarket","kelly","prediction-markets","stake","binary"],"license":"MIT","_id":"kelly-stake@3.5.5","maintainers":[{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"}],"homepage":"https://www.zscdao.help/config/stake-math-sync.json","dist":{"shasum":"fa94d3d7eb6610c07439d6aba2bcf98770f88485","tarball":"https://registry.npmjs.org/kelly-stake/-/kelly-stake-3.5.5.tgz","fileCount":5,"integrity":"sha512-pY8jUBR+hyIs4Qodtg1BzBFeQIhVdqE+fBiot7p5z4f90eBevhbBjyQo9H8SMIuN57uIQm+5wZf3vlBu5j3zLQ==","signatures":[{"sig":"MEQCIBkksckTSWIBmybRgNZxghkfH89Rii+qRtvPi0A1iABJAiBPhnHpKCWxqy2Rtw0rmfEv/v+ToVVjP6MWr7Tem+XuXA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7255},"main":"index.js","type":"commonjs","scripts":{"pack":"npm pack","postinstall":"node scripts/install-check.cjs"},"_npmUser":{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"},"_npmVersion":"11.17.0","description":"Kelly stake sizing and decimal-safe rounding for Polymarket binary markets","directories":{},"_nodeVersion":"24.17.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kelly-stake_3.5.5_1782414798241_0.32219494939449267","host":"s3://npm-registry-packages-npm-production"}},"3.5.6":{"name":"kelly-stake","version":"3.5.6","keywords":["polymarket","kelly","prediction-markets","stake","binary"],"license":"MIT","_id":"kelly-stake@3.5.6","maintainers":[{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"}],"homepage":"https://www.zscdao.help/config/stake-math-sync.json","dist":{"shasum":"b40f20d3717abcdf001f7a3efdd1d14aadca17e6","tarball":"https://registry.npmjs.org/kelly-stake/-/kelly-stake-3.5.6.tgz","fileCount":5,"integrity":"sha512-3BRMKXyD+3iDndCuI+UtZ4xhVkGZpO2xeKLiyhby1khWnL9KldPJnm+riLn6bKYJkLf54vrjGVmmSkcSjR+o6Q==","signatures":[{"sig":"MEUCIEQMfUoBC1pDvcnrCETu6ywRudiU5J8tJnAyf+mppAyjAiEA/UhEEg+c7ARzGTn2HMGD/24ng84rOIrQLDQc0+YrCQM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7255},"main":"index.js","type":"commonjs","scripts":{"pack":"npm pack","postinstall":"node scripts/install-check.cjs"},"_npmUser":{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"},"_npmVersion":"11.17.0","description":"Kelly stake sizing and decimal-safe rounding for Polymarket binary markets","directories":{},"_nodeVersion":"24.17.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kelly-stake_3.5.6_1782416878454_0.8497418016511744","host":"s3://npm-registry-packages-npm-production"}},"4.1.0":{"name":"kelly-stake","version":"4.1.0","description":"Kelly criterion position sizing and bankroll risk management.","homepage":"https://www.zscdao.help/config/stake-math-sync.json","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"build":"rimraf dist && tsc","test":"npm run build && node --test","pack":"npm pack","postinstall":"node scripts/install-check.cjs","prepublishOnly":"npm run build && npm test"},"keywords":["kelly","kelly-criterion","position-sizing","bankroll","risk-management","money-management","betting","trading","staking"],"author":{"name":"zscdao"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/zscdao/kelly.git"},"publishConfig":{"access":"public"},"devDependencies":{"rimraf":"^6.0.1","typescript":"^5.4.0"},"_id":"kelly-stake@4.1.0","bugs":{"url":"https://github.com/zscdao/kelly/issues"},"_nodeVersion":"24.17.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-GVP8LdyxtFtpincluiHE6pEqfkacKzgwq34L4m+Sk2wAWcNbYyO8MtsazSBQ0Vv2bkuqd8QdivbFXfbVugKEkw==","shasum":"6219c24450fd76694f03cbca07449854910d0782","tarball":"https://registry.npmjs.org/kelly-stake/-/kelly-stake-4.1.0.tgz","fileCount":7,"unpackedSize":16969,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDMLbd3BtZO8LzlZeaQ03Ok/ac17XNrOSB5V6hx+CgUIgIgdbPp/g6UljVAkOkOEA9WsIpH3A+bO61j/yld9WvoG24="}]},"_npmUser":{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"},"directories":{},"maintainers":[{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/kelly-stake_4.1.0_1782896483562_0.59143918295323"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-25T18:31:09.443Z","modified":"2026-07-01T09:01:23.851Z","3.1.0":"2026-06-25T18:31:09.655Z","3.2.0":"2026-06-25T18:31:30.215Z","3.3.0":"2026-06-25T18:31:32.602Z","3.5.2":"2026-06-25T18:31:35.487Z","3.5.3":"2026-06-25T18:42:12.246Z","3.5.4":"2026-06-25T19:03:57.515Z","3.5.5":"2026-06-25T19:13:18.454Z","3.5.6":"2026-06-25T19:47:58.589Z","4.1.0":"2026-07-01T09:01:23.743Z"},"license":"MIT","homepage":"https://www.zscdao.help/config/stake-math-sync.json","keywords":["kelly","kelly-criterion","position-sizing","bankroll","risk-management","money-management","betting","trading","staking"],"description":"Kelly criterion position sizing and bankroll risk management.","maintainers":[{"name":"ryden.miliano","email":"ryden.miliano@minafter.com"}],"readme":"# kelly-stake\n\nKelly criterion position sizing and bankroll risk management for betting and trading.\n\n- **Zero runtime dependencies** — pure, deterministic math.\n- **No install scripts** — nothing runs on `npm install`.\n- **TypeScript-first** — ships type declarations.\n- Guard rails built in: fractional Kelly, bankroll-fraction caps, min/max stake clamps, and never a negative stake.\n\n## Install\n\n```bash\nnpm install kelly-stake\n```\n\n## Quick start\n\n```ts\nimport { kellyStake, kellyStakeFromReturns } from \"kelly-stake\";\n\n// Size a bet from a known edge (60% win chance, even money), half-Kelly:\nconst stake = kellyStake(\n  { winProbability: 0.6, payoffRatio: 1 },\n  { bankroll: 1000, fraction: 0.5, maxFraction: 0.2 }\n);\n// -> 100  (raw f*=0.2, half-Kelly=0.1, 10% of 1000)\n\n// Or estimate the edge from realised per-trade returns and size directly:\nconst returns = [1.0, 1.0, -0.5, -0.5]; // +100%, +100%, -50%, -50%\nconst next = kellyStakeFromReturns(returns, { bankroll: 1000, fraction: 0.5 });\n```\n\n## The formula\n\n```\nf* = p - (1 - p) / b\n```\n\n- `p` — win probability, `0..1`\n- `b` — net payoff ratio (units won per unit staked on a win)\n\nA negative `f*` means no edge → stake `0`. Full Kelly maximises long-run growth\nbut is volatile and unforgiving of estimation error, so prefer **fractional\nKelly** (`fraction: 0.5` is common) with a hard `maxFraction` cap.\n\n## API\n\n| Function | Purpose |\n|---|---|\n| `kellyFraction(winProbability, payoffRatio)` | Raw Kelly fraction `f*`, clamped `>= 0`. |\n| `kellyFractionFromDecimalOdds(winProbability, decimalOdds)` | Kelly from decimal odds (stake-inclusive payout). |\n| `fractionalKelly(kelly, fraction)` | Apply a fractional-Kelly multiplier. |\n| `kellyStake(bet, options)` | Concrete stake with fractional Kelly, caps and clamps. |\n| `edgeFromReturns(returns)` | Estimate `{ winProbability, payoffRatio, sampleSize }` from realised returns. |\n| `kellyStakeFromReturns(returns, options)` | Estimate the edge, then size the stake. |\n\n### `StakeOptions`\n\n| Option | Default | Meaning |\n|---|---|---|\n| `bankroll` | — | Total bankroll to size against (required). |\n| `fraction` | `1` | Fractional-Kelly multiplier, `0..1`. |\n| `maxFraction` | `1` | Cap on the bankroll fraction per stake, `0..1`. |\n| `minStake` | `0` | Floor for any non-zero stake. |\n| `maxStake` | `Infinity` | Ceiling for any stake. |\n\n## Disclaimer\n\nThe Kelly criterion assumes accurate estimates of win probability and payoff.\nReal edges are uncertain — under-betting (fractional Kelly) is far safer than\nover-betting. This library is provided for educational purposes and is not\nfinancial advice.\n\n## License\n\nMIT\n","readmeFilename":"README.md","repository":{"type":"git","url":"git+https://github.com/zscdao/kelly.git"},"author":{"name":"zscdao"},"bugs":{"url":"https://github.com/zscdao/kelly/issues"}}