Dynamic position sizing algorithm development

We design and develop full-cycle blockchain solutions: from smart contract architecture to launching DeFi protocols, NFT marketplaces and crypto exchanges. Security audits, tokenomics, integration with existing infrastructure.
Showing 1 of 1 servicesAll 1306 services
Dynamic position sizing algorithm development
Medium
~3-5 business days
FAQ
Blockchain Development Services
Blockchain Development Stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1218
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    853
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1047
  • image_logo-advance_0.png
    B2B Advance company logo design
    561
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    823

Dynamic Position Sizing Algorithm Development

Dynamic position sizing adapts each position size based on current market conditions and portfolio state. Instead of fixed lot trading, algorithm calculates optimal size for each specific trade.

Fixed Fractional (Kelly-inspired)

Base approach: risk fixed capital percentage per trade.

def fixed_fractional_size(capital, risk_pct, entry_price, stop_price):
    risk_amount = capital * risk_pct
    risk_per_unit = abs(entry_price - stop_price)
    qty = risk_amount / risk_per_unit
    return qty

Standard risk_pct: 1–2% per trade. On 20 consecutive full-stop losses: loss (0.98)^20 = 33% deposit. Manageable.

Volatility-Adjusted Sizing

Position size inversely proportional to volatility: higher volatility → smaller position.

def volatility_adjusted_size(capital, target_risk_pct, atr, entry_price, atr_multiplier=2.0):
    risk_amount = capital * target_risk_pct
    stop_distance = atr * atr_multiplier  # stop at 2×ATR
    position_value = risk_amount / (stop_distance / entry_price)
    return position_value / entry_price  # in asset units

ATR 3% → stop 6% → size X. ATR 1% → stop 2% → size 3X. Result: equal monetary risk at different volatility.

Kelly Criterion

Mathematically optimal position size for maximizing long-term capital growth:

Kelly % = W - (1-W)/R
where W = win rate, R = avg win/avg loss

W=55%, R=1.5: Kelly = 0.55 - 0.45/1.5 = 0.25 = 25% capital.

Too aggressive. Usually Half Kelly (12.5%) or Quarter Kelly. Full Kelly causes huge drawdown despite theoretical optimality.

Drawdown-Based Scaling

Reduce positions approaching max drawdown:

def drawdown_scaled_size(base_size, current_equity, peak_equity, 
                          max_drawdown=0.20):
    current_dd = (peak_equity - current_equity) / peak_equity
    
    if current_dd > max_drawdown * 0.75:
        # At 75% max drawdown — reduce to 50% size
        return base_size * 0.5
    elif current_dd > max_drawdown * 0.5:
        # At 50% max drawdown — reduce to 75% size
        return base_size * 0.75
    
    return base_size

Correlation Adjustment

Portfolio already holds correlated positions — new adds less diversification. New position size reduces proportionally:

def correlation_adjusted_size(base_size, correlation_with_portfolio):
    # Correlation 0.8 → reduce to 20% of base
    diversity_factor = 1 - abs(correlation_with_portfolio)
    return base_size * max(diversity_factor, 0.2)  # minimum 20%

Develop dynamic position sizing system with configurable method combination: fixed fractional + volatility adjustment + drawdown scaling + correlation adjustment. Single module, integrates any trading strategy.