Article


The "Mathematical Barriers" in Trading: Three Little-Known Algorithms That Determine 90% of Profits and Losses

Brother Hao
21 days ago
Brothers, today we’re not talking about market ups and downs, nor about panic and greed. Let’s discuss something deeper and more hardcore—the “mathematical algorithms” that truly control your every trade’s profit and loss behind the scenes.

You may be proficient in various technical patterns and well-versed in interpreting news, but if you don’t understand these three core algorithms below, your trading is like building a house on quicksand—always lacking a solid foundation. They are the “source code” of your strategy. Understanding them allows you to evolve from a “feeling trader” to a “system architect.”

Algorithm One: The Kelly Formula (The “Holy Grail” of Position Sizing)—Deciding How Much to Bet

Most traders get wiped out by their position sizing: either too conservative, missing out on opportunities; or too aggressive, going to zero in one shot. The Kelly formula is the mathematical optimal solution to this century’s dilemma.

It doesn’t predict market movements; it answers only one question: Given your win rate and risk-reward ratio, what is the optimal position size to maximize long-term compound growth while avoiding bankruptcy?

Kelly Formula: f = ((bp - q)) / b

f: The proportion of your capital to invest (position size)

b: Your risk-reward ratio (profit/loss)

p: Your win rate

q: Your loss rate (1 - p)

Practical example:
Suppose your “Turtle Rest Strategy” has been backtested over 100 trades, with a win rate (p) of 70%, and an average risk-reward ratio (b) of 1.2:1 (profit 1.2, loss 1).

Calculation: f = (1.2 * 0.7 - 0.3) / 1.2 = (0.84 - 0.3) / 1.2 = 0.54 / 1.2 = 0.45

Result: According to the Kelly formula, in this case, your optimal single-trade risk exposure should be 45% of your total capital. But note, this is a theoretical maximum. In actual trading, we usually adopt “half-Kelly” or “quarter-Kelly” to mitigate model errors and black swan events—practically controlling position sizes at 11%-22.5%.

Your action checklist:

- Calculate your main strategies’ (like Turtle Rest, Kunpeng) historical win rates (p) and average risk-reward ratios (b).

- Plug these values into the Kelly formula to determine the theoretical optimal position size (f).

- Divide the result by 2 or 4, as your maximum position discipline in live trading. From now on, your position size is no longer “feelings,” but “mathematics.”

Algorithm Two: The Sharpe Ratio (The “Benchmark” for Strategy Evaluation)—Telling You Which Strategy is “Better”

When you have multiple strategies (e.g., Turtle Rest’s stability and Kunpeng’s boldness), how do you allocate funds scientifically? Based on intuition? Recent profits? Wrong. You need a measure of a strategy’s “cost-effectiveness”—the Sharpe ratio.

It measures: How much excess return can your strategy generate per unit of risk (volatility)? The higher the Sharpe ratio, the better the strategy’s “risk-adjusted return,” and the more funds you should allocate.

Sharpe Ratio = ((Strategy Average Return - Risk-Free Rate)) / Standard Deviation of Strategy Returns

Strategy average return: Your strategy’s historical annualized return.

Risk-free rate: Usually the government bond yield (can be simplified to 0).

Standard deviation of strategy returns: Represents the volatility (risk) of your strategy’s returns.

Strategy comparison example:

- Strategy A (Turtle Rest): Annualized return of 20%, with steady monthly performance and low volatility (standard deviation about 5%). Sharpe ≈ (20% - 0) / 5% = 4

- Strategy B (Kunpeng): Annualized return up to 50%, but with large swings and high volatility (standard deviation about 25%). Sharpe ≈ (50% - 0) / 25% = 2

Conclusion: Although Strategy B’s absolute return is higher, Strategy A’s Sharpe ratio (4) far exceeds Strategy B’s (2). This indicates that, per unit of risk taken, Strategy A yields more return. Therefore, in your overall asset allocation, Strategy A should occupy a more core and stable position.

Your action checklist:

- Calculate (or estimate) the long-term Sharpe ratio for each of your trading strategies.

- Prioritize allocating funds to strategies with higher Sharpe ratios, building your “core-satellite” portfolio.

Algorithm Three: Monte Carlo Simulation (The “Lens” for Bankruptcy Risk)—Telling You “Whether You Will Die”

This is the nuclear weapon of institutional risk control, but you can grasp the principle. It doesn’t predict the outcome of a single trade; instead, through thousands of computer simulations, it tells you the probability that your trading system will go bankrupt (drawdown exceeding limits) under various possible market paths.

It answers a crucial question: In the worst-case scenario, can my method survive?

Simulation steps (thought experiment):

- Input your system parameters: win rate, risk-reward ratio, position rules (e.g., Kelly result), total capital.

- Let the computer generate thousands of possible price sequences based on historical volatility.

- Run your trading system automatically on each simulated path, recording the final results.

Key insights you will gain:

- How many times out of 10,000 simulations does your system hit a 50% maximum drawdown (approaching bankruptcy)?

- What does your worst-case capital curve look like?

- How much initial capital do you need to keep the bankruptcy probability below 1%?

The significance for you: If Monte Carlo simulations show a bankruptcy probability of 30%, no matter how brilliant the past performance, it’s a fragile “time bomb.” Conversely, if the bankruptcy probability is below 1%, you can sleep soundly through bull and bear markets.

Ultimate Integration: Building Your “Trading Holy Grail” with Mathematics

Now, by integrating these three major algorithms, you have a complete framework for self-checking and optimizing your system:

- Use the Kelly formula to determine scientific position sizes for each signal.

- Use the Sharpe ratio to allocate funds scientifically among different strategies.

- Use Monte Carlo simulations to stress-test your entire portfolio, ensuring survivability.

The highest level of trading is not to become a prediction master but a master of probability and risk management. These cold, mathematical formulas are your most reliable and solid armor in a market driven by emotions and news.

From now on, your trading logs should include not only “bullish,” “bearish,” but also “This position was opened based on the Kelly formula with half position,” “Current portfolio Sharpe ratio maintained above 2.0,” “Monte Carlo simulation shows bankruptcy probability <0.5%.”

When your trading decisions leap from candlestick charts to mathematical formulas, you have truly made the daring leap from amateur to professional.

(In the Whale Club, we not only share strategies but also deeply dissect the mathematical engines behind them. From optimizing Turtle Rest’s grid parameters to designing Kunpeng’s position sequences, every step is validated by mathematical models. If you’re no longer satisfied with surface-level buy/sell signals and crave insight into the deep mathematical logic that governs the market, this is the place you should be.)
View Original
post-image
post-image
post-image
This page may contain third-party content, which is provided for information purposes only (not representations/warranties) and should not be considered as an endorsement of its views by Gate, nor as financial or professional advice. See Disclaimer for details.
  • Reward
  • Comment
  • Repost
  • Share
Comment
0/400
No comments
  • Pin

Trade Crypto Anywhere Anytime
qrCode
Scan to download Gate App
Community
  • 简体中文
  • English
  • Tiếng Việt
  • 繁體中文
  • Español
  • Русский
  • Français (Afrique)
  • Português (Portugal)
  • Bahasa Indonesia
  • 日本語
  • بالعربية
  • Українська
  • Português (Brasil)