Skip to content
capital-proportional-limits logo

Capital Manager Proportional Limits

capital-proportional-limits

Use percentage-based capital limits, not hard-coded dollar amounts. Trigger when: (1) trades blocked on small accounts, (2) min_cash_buffer is absolute dollars, (3) capital allocation doesn't scale with account size, (4) fixed dollar thresholds in risk code.

SKILL.md

Full skill instructions

Capital Manager Proportional Limits

Experiment Overview

ItemDetails
Date2024-12-24
GoalFix capital manager blocking trades with hard-coded dollar amounts
Environmentscripts/​live_trader.py, alpaca_trading/​risk/​capital_manager.py
StatusSuccess

Context

The capital manager was initialized with min_cash_buffer=1000.0 - a fixed dollar amount that:

  1. Blocked 20% of a $5,000 account - Leaving only $4,000 for trading
  2. Blocked 10% of a $10,000 account - Still significant
  3. Blocked only 1% of a $100,000 account - Negligible

The 30% safety buffer (percentage-based) already provides proportional protection. The extra $1,000 was redundant and harmful for smaller accounts.

Verified Workflow

Problem Pattern

# WRONG: Hard-coded dollar amount
capital_mgr = CapitalManager(
    safety_buffer_pct=0.30,
    trading_allocation_pct=0.70,
    max_position_pct=0.20,
    min_cash_buffer=1000.0  # <-- Blocks 20% of $5k account!
)

Solution: Use Percentage-Based Limits

# CORRECT: Let percentage-based safety buffer handle it
capital_mgr = CapitalManager(
    safety_buffer_pct=0.30,       # 30% safety buffer (proportional)
    trading_allocation_pct=0.70,  # 70% available for trading
    max_position_pct=0.20,        # 20% max per position
    # min_cash_buffer defaults to 0.0 - safety buffer is proportional
)

Capital Manager Design

The CapitalManager class is correctly designed with percentage-based defaults:

class CapitalManager:
    def __init__(
        self,
        safety_buffer_pct: float = 0.30,      # 30% reserved
        trading_allocation_pct: float = 0.70,  # 70% for trading
        max_position_pct: float = 0.20,        # 20% max per position
        min_cash_buffer: float = 0.0,          # Additional cash buffer (default: none)
        min_trade_value: float = 1.0           # Supports fractional shares
    ):

The min_cash_buffer parameter exists for edge cases but should rarely be used since the percentage-based safety buffer already scales with account size.

Impact Analysis

Account SizeOld (with $1,000 buffer)New (0% buffer)Improvement
$5,000$4,000 available$5,000 available+25%
$10,000$9,000 available$10,000 available+11%
$50,000$49,000 available$50,000 available+2%
$100,000$99,000 available$100,000 available+1%

Note: The 30% safety buffer still applies to all accounts, so actual trading capital is 70% of these values.

Failed Attempts (Critical)

AttemptWhy it FailedLesson Learned
Hard-coded $1,000 min_cash_bufferDisproportionately hurt small accountsUse percentage-based limits only
Hard-coded $50 in strategiesSame problem at smaller scaleRemove absolute dollar amounts
Fixed confidence thresholdsDidn't adapt to volatility regimesConsider adaptive thresholds
Hard-coded stop-loss percentagesDidn't account for asset volatilityConsider asset-specific thresholds

Key Insights

Percentage-Based vs Dollar-Based

ApproachProsConsWhen to Use
Percentage-basedScales with account, fair to all sizesMay allow tiny trades on small accountsDefault - almost always
Dollar-basedPrevents dust tradesUnfair to small accounts, doesn't scaleOnly for minimum trade value

Other Hard-Coded Values to Watch

These were identified during investigation (not fixed yet):

# In live_trader.py - consider making configurable:
confidence = 0.6       # Default fallback confidence
rl_confidence < 0.4    # Minimum RL confidence threshold
confidence < 0.70      # Extreme volatility threshold
base_breakeven = 0.02  # 2% breakeven stop
base_trailing = 0.05   # 5% trailing stop

# In harmonized.py:
min_cash_buffer = 50.0  # Should also be removed

The 30% Safety Buffer

The existing safety buffer provides strong protection:

# How it works:
conservative_value = account_value - unrealized_profits + unrealized_losses
safety_buffer = conservative_value * 0.30  # 30% reserved
available_capital = conservative_value * 0.70  # 70% for trading

# For a $10,000 account:
# - Safety buffer: $3,000 (never touched)
# - Trading capital: $7,000
# - Max per position: $1,400 (20% of $7,000)

Files Modified

scripts/​live_trader.py:
  - Line 1751-1756: Removed min_cash_buffer=1000.0
  - Added comment explaining proportional protection

References

  • alpaca_trading/​risk/​capital_manager.py: Lines 74-100 (class design)
  • scripts/​live_trader.py: Lines 1750-1757 (initialization)
  • CLAUDE.md: Risk Controls section

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View