Nija

Capital Capacity Calculator - User Guide

Overview

The NIJA Capital Capacity Calculator provides comprehensive analysis of your trading capital, showing exactly how much you can deploy and what your maximum position size should be for any account.

Key Metrics

1. Total Equity

Your complete account value including:

Formula: Total Equity = Available Cash + Position Value

2. Deployable Capital

The amount of capital available for new positions, accounting for:

Formula: Deployable Capital = (Total Equity Γ— (1 - Reserve%)) - Current Positions

3. Maximum Position Size

The largest single position you can open, constrained by:

Formula: Max Position = min(Total Equity Γ— Max%, Deployable Capital, Available Cash)

Usage

Single Account Analysis

Calculate capital capacity for one account:

# Account with $10,000 balance and $2,000 in open positions
python calculate_capital_capacity.py --balance 10000 --positions 2000

# Small account with no positions
python calculate_capital_capacity.py --balance 500

# Custom reserve (15%) and max position (20%)
python calculate_capital_capacity.py --balance 10000 --positions 2000 --reserve-pct 15 --max-position-pct 20

Parameters:

All Accounts Analysis

Calculate for platform account + all user accounts:

# Display all accounts from portfolio manager
python calculate_all_accounts_capital.py

# Run with simulated example accounts
python calculate_all_accounts_capital.py --simulate

# Custom settings for all accounts
python calculate_all_accounts_capital.py --simulate --max-position-pct 20 --reserve-pct 15

Features:

Example Output

Single Account

================================================================================
CAPITAL CAPACITY ANALYSIS - Account
================================================================================

πŸ’° ACCOUNT BALANCES:
   Total Equity: $12,000.00
   Available Cash: $10,000.00
   Position Value: $2,000.00
   Unrealized P/L: $+0.00

πŸ“Š POSITION METRICS:
   Open Positions: 1
   Cash Utilization: 16.7%

🎯 CAPITAL DEPLOYMENT:
   Min Reserve Required: 10.0% ($1,200.00)
   Max Deployable Total: $10,800.00
   Currently Deployed: $2,000.00
   ──────────────────────────────────────
   EFFECTIVE DEPLOYABLE CAPITAL: $8,800.00

πŸ“ POSITION SIZING:
   Max Position %: 15.0%
   ──────────────────────────────────────
   MAX POSITION SIZE: $1,800.00

πŸ“ˆ CAPACITY METRICS:
   Deployment Capacity Used: 18.5%
   Remaining Capacity: $8,800.00

πŸ’‘ RECOMMENDATIONS:
   βœ… HEALTHY CAPACITY: Can open new positions up to $1,800.00
   πŸ’Ό LOW UTILIZATION: 16.7% of equity is in positions
   β†’ Significant capital available for deployment

All Accounts

================================================================================
NIJA ALL ACCOUNTS CAPITAL CAPACITY CALCULATOR
================================================================================

🎯 Platform Account (Master)
──────────────────────────────────────────────────────────────────────────────
  Total Equity:        $   24,600.00
  Available Cash:      $   20,000.00
  Position Value:      $    4,600.00
  Open Positions:                 1
  Utilization:                18.7%
  ────────────────────────────────────────────────
  πŸ’° Deployable Capital: $ 17,540.00
  πŸ“ Max Position Size:  $  3,690.00

================================================================================
AGGREGATE SUMMARY - ALL 4 ACCOUNTS
================================================================================

πŸ’Ό PORTFOLIO TOTALS:
   Total Equity (All Accounts):     $      42,770.00
   Total Available Cash:             $      27,500.00
   Total Position Value:             $      15,270.00
   Total Open Positions:                           4
   Average Utilization:                        35.5%

🎯 AGGREGATE CAPACITY:
   Combined Deployable Capital:      $      23,223.00
   Combined Max Position Size:       $       6,410.50

Programmatic Usage

In Python Code

from bot.portfolio_state import PortfolioState

# Create portfolio state
portfolio = PortfolioState(available_cash=10000.0, min_reserve_pct=0.10)

# Add positions
portfolio.add_position("BTC-USD", 0.1, 45000, 46000)

# Calculate deployable capital
deployable = portfolio.calculate_deployable_capital()
print(f"Deployable: ${deployable:.2f}")

# Calculate max position size
max_position = portfolio.calculate_max_position_size(max_position_pct=0.15)
print(f"Max Position: ${max_position:.2f}")

# Get full breakdown
breakdown = portfolio.get_capital_breakdown()
print(f"Total Equity: ${breakdown['total_equity']:.2f}")
print(f"Deployable: ${breakdown['deployable_capital']:.2f}")
print(f"Max Position: ${breakdown['max_position_size']:.2f}")

With Portfolio Manager

from bot.portfolio_state import get_portfolio_manager

# Get portfolio manager
mgr = get_portfolio_manager()

# Initialize master portfolio
master = mgr.initialize_master_portfolio(available_cash=25000.0)
master.add_position("BTC-USD", 0.2, 45000, 46000)

# Get capital breakdown
breakdown = master.get_capital_breakdown(
    max_position_pct=0.15,
    min_reserve_pct=0.10
)

print(f"Platform Account:")
print(f"  Total Equity: ${breakdown['total_equity']:.2f}")
print(f"  Deployable: ${breakdown['deployable_capital']:.2f}")
print(f"  Max Position: ${breakdown['max_position_size']:.2f}")

Understanding the Calculations

Example Scenario

Account State:

With 10% Reserve and 15% Max Position:

  1. Total Equity = $12,000 (cash + positions)

  2. Min Reserve = $12,000 Γ— 10% = $1,200
    • Must always keep this much available
  3. Max Deployable = $12,000 - $1,200 = $10,800
    • Maximum that can ever be in positions
  4. Current Deployed = $2,000
    • Already have this much in positions
  5. Deployable Capital = $10,800 - $2,000 = $8,800
    • Can still deploy this much
  6. Max Position by % = $12,000 Γ— 15% = $1,800
    • Single position limit based on equity
  7. Max Position Size = min($1,800, $8,800, $10,000) = $1,800
    • Limited by the percentage rule

Best Practices

Reserve Requirements

Conservative (15-20%):

Moderate (10-15%):

Aggressive (5-10%):

Position Sizing

Conservative (10-12%):

Moderate (15-20%):

Aggressive (20-25%):

Integration with Trading Bot

The capital capacity calculations are integrated into:

  1. Portfolio State Management
    • Real-time tracking of deployable capital
    • Automatic calculation with each balance update
  2. Risk Manager
    • Position sizing uses deployable capital
    • Respects maximum position limits
  3. Trade Execution
    • Validates against deployable capital
    • Prevents over-deployment
  4. User Account Management
    • Each user has independent capacity calculation
    • Platform account controls overall strategy

Troubleshooting

β€œNo deployable capital available”

Causes:

Solutions:

β€œMax position size too small”

Causes:

Solutions:

β€œNegative deployable capital”

This should never happen, but if it does:

FAQs

Q: Why use total equity instead of just cash? A: Total equity gives a complete picture of your account value. Cash-only calculations ignore the capital you have in positions, leading to over-trading.

Q: What’s the right reserve percentage? A: Most traders use 10-15%. Higher is safer but less capital efficient. Lower is more aggressive.

Q: Can I set different reserves per account? A: Yes, each PortfolioState can have its own min_reserve_pct.

Q: How often should I recalculate? A: Automatically done with each balance update. Manual checks useful before major trades.

Q: What if I want to deploy 100% of capital? A: Set min_reserve_pct=0.0, but this is risky and not recommended.

See Also