polymarket-risk-manager 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/index.js +29 -0
- package/package.json +10 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# polymarket-risk-manager
|
|
2
|
+
|
|
3
|
+
Kelly-criterion stake sizing for Polymarket-style binary markets.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install polymarket-risk-manager
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API (3.1.0)
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
const { computeKellyStake } = require('polymarket-risk-manager');
|
|
15
|
+
|
|
16
|
+
computeKellyStake({
|
|
17
|
+
probability: 0.58,
|
|
18
|
+
allInPrice: 0.52,
|
|
19
|
+
bankroll: 500,
|
|
20
|
+
maxStake: 25,
|
|
21
|
+
minStake: 5,
|
|
22
|
+
kellyFraction: 0.5,
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Licence
|
|
27
|
+
|
|
28
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** @deprecated use computeKellyStake from 3.2+ for formatted output */
|
|
4
|
+
function computeKellyStake({
|
|
5
|
+
probability,
|
|
6
|
+
allInPrice,
|
|
7
|
+
bankroll,
|
|
8
|
+
maxStake,
|
|
9
|
+
minStake = 0,
|
|
10
|
+
kellyFraction = 0.5,
|
|
11
|
+
}) {
|
|
12
|
+
if (
|
|
13
|
+
!Number.isFinite(probability) ||
|
|
14
|
+
!Number.isFinite(allInPrice) ||
|
|
15
|
+
!Number.isFinite(bankroll) ||
|
|
16
|
+
allInPrice <= 0 ||
|
|
17
|
+
allInPrice >= 1
|
|
18
|
+
) {
|
|
19
|
+
return minStake;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const rawKelly = (probability - allInPrice) / (1 - allInPrice);
|
|
23
|
+
if (rawKelly <= 0) return minStake;
|
|
24
|
+
|
|
25
|
+
const stake = bankroll * rawKelly * kellyFraction;
|
|
26
|
+
return Math.min(maxStake, Math.max(minStake, stake));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = { computeKellyStake };
|
package/package.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "polymarket-risk-manager",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "Polymarket Kelly stake sizing and decimal-safe rounding for binary markets",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"files": ["index.js", "README.md"],
|
|
7
|
+
"keywords": ["polymarket", "kelly", "prediction-markets", "stake"],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"type": "commonjs"
|
|
10
|
+
}
|