Optimal Leverage Sequencing in Leveraged Dollar Cost Averaging

Inspiration

Dollar Cost Averaging (DCA) is one of the most widely used investment strategies, yet one question remains largely unanswered:

If the total leverage is fixed, how should that leverage be distributed across DCA entries?

Most traders either use the same leverage for every entry or rely on intuition. I wanted to determine whether there is a mathematically optimal allocation that is independent of market conditions.

This project began as an attempt to answer that question rigorously rather than through trial and error.


What it does

The project proves that among all leverage sequences with the same total leverage, the non-decreasing (increasing) leverage sequence is uniquely optimal.

Instead of allocating leverage equally,

[6, 6, 6, 6, 6]

or decreasing it,

[10, 8, 6, 4, 2]

the optimal allocation is

[2, 4, 6, 8, 10]

The proof shows that increasing leverage minimizes the weighted average entry price while maximizing the distance between the market reference price and the average entry.

The theoretical result is then validated through extensive historical backtests across multiple asset classes.


The Mathematics

For leverage values

[ L_1,L_2,\ldots,L_n ]

with fixed total leverage

[ \sum_{i=1}^{n}L_i=C, ]

and DCA entry prices

[ P_1>P_2>\cdots>P_n, ]

the weighted average entry price is

[ \bar P=\frac{\sum_iL_iP_i}{\sum_iL_i}. ]

Applying the Rearrangement Inequality shows that pairing the largest leverage with the lowest prices uniquely minimizes the weighted average entry.

The result is completely parameter-independent and does not depend on the specific asset being traded.


How I built it

The project consists of two major parts.

Mathematical Proof

  • Derived the optimization problem
  • Applied the Rearrangement Inequality
  • Proved uniqueness of the optimal solution
  • Wrote the complete manuscript in LaTeX

Research & Backtesting

I implemented a complete research pipeline in Python using:

  • Pandas
  • NumPy
  • Matplotlib
  • PyArrow

The framework supports:

  • XAUUSD (Gold)
  • BTCUSDT
  • ETHUSDT
  • SPY
  • QQQ

The backtest processes approximately 9.5 million one-minute candles spanning 2021–2026.

Each leverage sequence is evaluated using identical trading rules so that only the leverage allocation changes.


Challenges

The biggest challenge was ensuring the theoretical proof translated into practical trading performance.

Backtesting leveraged DCA fairly required:

  • preventing look-ahead bias
  • handling rolling reference highs
  • modeling liquidation correctly
  • keeping every strategy identical except leverage ordering
  • processing millions of candles efficiently

Another challenge was proving that the result was not specific to one market. Testing across commodities, cryptocurrencies, and equity ETFs helped demonstrate the robustness of the theory.


Results

Across every tested market, the increasing leverage sequence produced the best overall performance.

Highlights include:

  • Highest Sharpe ratio across all five assets
  • Lowest liquidation count in every market
  • Improved average entry prices
  • Better recovery performance after market reversals

The probability of obtaining first place in all five markets by chance is approximately

[ \left(\frac13\right)^5\approx0.004. ]


What I learned

This project reinforced that rigorous mathematics can produce practical improvements in quantitative trading.

I gained deeper experience in:

  • mathematical optimization
  • quantitative finance
  • statistical validation
  • large-scale historical backtesting
  • research writing in LaTeX
  • financial software engineering

What's next

Future work includes extending the theory to:

  • adaptive leverage schedules
  • volatility-aware DCA
  • portfolio-level optimization
  • reinforcement learning for dynamic leverage allocation
  • institutional-scale execution systems

Ultimately, the goal is to bridge rigorous mathematical research with practical quantitative investment strategies that can be tested, reproduced, and improved by the wider research community.

Built With

  • algorithmic
  • analysis
  • backtesting
  • cryptocurrency
  • data
  • engineering
  • finance
  • financial
  • gold
  • latex
  • mathematics
  • matplotlib
  • numpy
  • optimization
  • pandas
  • pyarrow
  • python
  • quantitative
  • research
  • science
  • series
  • spy
  • statistics
  • time
  • trading
Share this project:

Updates