| Overall Statistics |
|
Total Orders 845 Average Win 0.33% Average Loss -0.01% Compounding Annual Return 21.103% Drawdown 29.000% Expectancy 45.369 Start Equity 1000000 End Equity 6837125.63 Net Profit 583.713% Sharpe Ratio 0.922 Sortino Ratio 0.998 Probabilistic Sharpe Ratio 56.518% Loss Rate 3% Win Rate 97% Profit-Loss Ratio 46.73 Alpha 0.058 Beta 0.774 Annual Standard Deviation 0.136 Annual Variance 0.018 Information Ratio 0.497 Tracking Error 0.079 Treynor Ratio 0.162 Total Fees $1225.25 Estimated Strategy Capacity $1600000.00 Lowest Capacity Asset IYW RUTTRZ1RC7L1 Portfolio Turnover 0.21% Drawdown Recovery 600 |
# ================================================================================
# REB01 - Rebalancing Strategy
# ================================================================================
# Author: Angus Li
# Date: January 14, 2026
#
# ⚠️ DISCLAIMER - FOR EDUCATIONAL & BACKTESTING PURPOSES ONLY ⚠️
#
# This code is provided for demonstration and educational purposes only.
# It is NOT intended for live trading without proper due diligence, risk
# management, and thorough testing in paper trading environments.
#
# Past performance does not guarantee future results. The author assumes
# NO LIABILITY for any financial losses, damages, or adverse outcomes
# resulting from the use of this code in live trading environments.
#
# By using this code, you acknowledge that:
# - You trade at your own risk
# - You are solely responsible for your trading decisions
# - The author is not a financial advisor
# - This is not financial advice
#
# Always consult with qualified financial professionals before making
# investment decisions.
# ================================================================================
# region imports
from AlgorithmImports import *
# endregion
# lean project-create --language python "REB01"
# lean cloud backtest "REB01" --push --open
class REB01(QCAlgorithm):
def initialize(self):
self.set_start_date(2016, 1, 1)
self.set_cash(1000000)
self.set_benchmark("SPY")
self._stock = "IYW"
self._gold = "GLD"
self.assets = [self._stock, self._gold]
# Add Equity ------------------------------------------------
for ticker in self.assets:
self.add_equity(ticker, Resolution.HOUR).symbol
self.schedule.on(self.date_rules.week_start("SPY"),
self.time_rules.after_market_open("SPY", 1),
self.every_day_before_market_close)
def every_day_before_market_close(self):
self.set_holdings([PortfolioTarget(self._gold, 0.4), PortfolioTarget(self._stock, 0.6)])