sizing
Position sizing with Kelly criterion and bankroll management
What this skill does
# Sizing - Complete API Reference
Calculate optimal position sizes using Kelly criterion, fractional Kelly, and portfolio-level allocation.
---
## Chat Commands
### Kelly Calculator
```
/kelly 0.45 0.55 10000 Market price, your prob, bankroll
/kelly "Trump 2028" 0.55 --bank 10k Calculate for specific market
/kelly --half 0.45 0.55 10000 Half Kelly (safer)
/kelly --quarter 0.45 0.55 10000 Quarter Kelly (conservative)
```
### Position Sizing
```
/size 10000 --risk 2% Size for 2% risk per trade
/size 10000 --max-position 25% Max 25% in single position
/size portfolio --rebalance Rebalance to target weights
```
### Edge Calculation
```
/edge 0.45 0.55 Calculate edge (prob - price)
/edge "Trump 2028" --estimate 0.55 Edge vs market price
```
---
## TypeScript API Reference
### Create Sizing Calculator
```typescript
import { createSizingCalculator } from 'clodds/sizing';
const sizing = createSizingCalculator({
// Bankroll
bankroll: 10000,
// Kelly fraction (1 = full, 0.5 = half)
kellyFraction: 0.5,
// Limits
maxPositionPercent: 25,
maxTotalExposure: 80,
});
```
### Basic Kelly
```typescript
// Binary outcome (YES/NO market)
const size = sizing.kelly({
marketPrice: 0.45, // Current price
estimatedProb: 0.55, // Your probability estimate
bankroll: 10000,
});
console.log(`Optimal bet: $${size.optimalSize}`);
console.log(`Edge: ${size.edge}%`);
console.log(`Kelly %: ${size.kellyPercent}%`);
console.log(`Expected value: $${size.expectedValue}`);
```
### Fractional Kelly
```typescript
// Half Kelly (recommended for most traders)
const halfKelly = sizing.kelly({
marketPrice: 0.45,
estimatedProb: 0.55,
bankroll: 10000,
fraction: 0.5, // Half Kelly
});
// Quarter Kelly (very conservative)
const quarterKelly = sizing.kelly({
marketPrice: 0.45,
estimatedProb: 0.55,
bankroll: 10000,
fraction: 0.25,
});
console.log(`Full Kelly: $${sizing.kelly({...}).optimalSize}`);
console.log(`Half Kelly: $${halfKelly.optimalSize}`);
console.log(`Quarter Kelly: $${quarterKelly.optimalSize}`);
```
### Multi-Outcome Kelly
```typescript
// For markets with 3+ outcomes
const multiKelly = sizing.kellyMultiOutcome({
outcomes: [
{ name: 'Trump', price: 0.35, estimatedProb: 0.40 },
{ name: 'DeSantis', price: 0.25, estimatedProb: 0.20 },
{ name: 'Haley', price: 0.15, estimatedProb: 0.15 },
{ name: 'Other', price: 0.25, estimatedProb: 0.25 },
],
bankroll: 10000,
fraction: 0.5,
});
for (const alloc of multiKelly.allocations) {
console.log(`${alloc.name}: $${alloc.size} (${alloc.percent}%)`);
}
```
### Portfolio-Level Kelly
```typescript
// Optimal allocation across multiple markets
const portfolio = sizing.kellyPortfolio({
positions: [
{ market: 'Trump 2028', price: 0.45, prob: 0.55 },
{ market: 'Fed Rate Cut', price: 0.60, prob: 0.70 },
{ market: 'BTC > 100k', price: 0.30, prob: 0.40 },
],
bankroll: 10000,
correlations: correlationMatrix, // Optional
fraction: 0.5,
});
console.log('Optimal Portfolio:');
for (const pos of portfolio.positions) {
console.log(` ${pos.market}: $${pos.size}`);
}
console.log(`Total exposure: ${portfolio.totalExposure}%`);
```
### Confidence-Adjusted Sizing
```typescript
// Reduce size when less confident
const size = sizing.kellyWithConfidence({
marketPrice: 0.45,
estimatedProb: 0.55,
confidence: 0.7, // 70% confident in estimate
bankroll: 10000,
});
// Size is reduced proportionally to confidence
console.log(`Confidence-adjusted size: $${size.optimalSize}`);
```
### Edge Calculation
```typescript
// Calculate edge
const edge = sizing.calculateEdge({
marketPrice: 0.45,
estimatedProb: 0.55,
});
console.log(`Edge: ${edge.edgePercent}%`);
console.log(`EV per dollar: $${edge.evPerDollar}`);
console.log(`Implied odds: ${edge.impliedOdds}`);
console.log(`True odds: ${edge.trueOdds}`);
```
### Risk-Based Sizing
```typescript
// Size based on risk per trade
const size = sizing.riskBased({
bankroll: 10000,
riskPercent: 2, // Risk 2% per trade
stopLossPercent: 10, // 10% stop loss
});
console.log(`Position size: $${size.positionSize}`);
console.log(`Max loss: $${size.maxLoss}`);
```
---
## Kelly Fractions
| Fraction | Risk Level | Use Case |
|----------|------------|----------|
| **Full (1.0)** | Aggressive | Mathematical optimum, high variance |
| **Half (0.5)** | Moderate | Most traders, good balance |
| **Quarter (0.25)** | Conservative | New traders, uncertain edges |
| **Tenth (0.1)** | Very Safe | Learning, small edges |
---
## Edge Requirements
| Edge | Recommendation |
|------|----------------|
| < 2% | Don't trade |
| 2-5% | Small size (quarter Kelly) |
| 5-10% | Normal size (half Kelly) |
| 10%+ | Larger size, verify edge |
---
## Formulas
### Kelly Formula
```
f* = (p * b - q) / b
Where:
f* = fraction of bankroll to bet
p = probability of winning
q = probability of losing (1 - p)
b = odds received (1/price - 1)
```
### Edge Formula
```
Edge = Estimated Prob - Market Price
EV = Edge * Bet Size
```
---
## Best Practices
1. **Use fractional Kelly** — Full Kelly has too much variance
2. **Be conservative on edge** — Overconfidence kills accounts
3. **Account for correlation** — Don't over-expose to same theme
4. **Set max position** — Never more than 25% in one market
5. **Reassess regularly** — Edge changes as prices move
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.