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.
Your complete account value including:
Formula: Total Equity = Available Cash + Position Value
The amount of capital available for new positions, accounting for:
Formula: Deployable Capital = (Total Equity Γ (1 - Reserve%)) - Current Positions
The largest single position you can open, constrained by:
Formula: Max Position = min(Total Equity Γ Max%, Deployable Capital, Available Cash)
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:
--balance: Account balance (total cash available)--positions: Total value of open positions (default: 0)--unrealized-pnl: Unrealized P/L from positions (default: 0)--reserve-pct: Minimum reserve % to maintain (default: 10)--max-position-pct: Maximum position size as % of equity (default: 15)--account-name: Account name for displayCalculate 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:
================================================================================
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
================================================================================
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
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}")
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}")
Account State:
With 10% Reserve and 15% Max Position:
Total Equity = $12,000 (cash + positions)
Conservative (15-20%):
Moderate (10-15%):
Aggressive (5-10%):
Conservative (10-12%):
Moderate (15-20%):
Aggressive (20-25%):
The capital capacity calculations are integrated into:
Causes:
Solutions:
Causes:
Solutions:
This should never happen, but if it does:
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.
TRADE_SIZE_TUNING_GUIDE.md - Position sizing strategiesRISK_PROFILES_GUIDE.md - Risk management guidelinesUSER_BALANCE_GUIDE.md - Account balance managementportfolio_state.py - Source code documentation