Overall Statistics
Total Trades
458
Average Win
0.59%
Average Loss
-0.12%
Compounding Annual Return
63.525%
Drawdown
30.500%
Expectancy
3.324
Net Profit
117.591%
Sharpe Ratio
1.519
Probabilistic Sharpe Ratio
64.615%
Loss Rate
25%
Win Rate
75%
Profit-Loss Ratio
4.80
Alpha
-0.102
Beta
0.486
Annual Standard Deviation
0.309
Annual Variance
0.096
Information Ratio
-2.16
Tracking Error
0.327
Treynor Ratio
0.968
Total Fees
$2006.40
Estimated Strategy Capacity
$16000000.00
Lowest Capacity Asset
BTCUSDT 18N
# CRYPTO USDT Rebalance

CRYPTO = "BTCUSDT"; TARGET = 0.5; TARGET_DIFF = 0.02; 

class CryptoUsdtRebalance(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2020, 9, 1)   
        self.SetEndDate(2022, 3, 31) 
        self.SetCash("USDT", 100000)
        self.SetBrokerageModel(BrokerageName.Binance, AccountType.Margin)
        self.crypto = self.AddCrypto(CRYPTO, Resolution.Hour).Symbol


    def OnData(self, data):
        real_wt_crypto = self.ActiveSecurities[self.crypto].Holdings.Quantity * self.Securities[self.crypto].Price / self.Portfolio.TotalPortfolioValue   
        if  real_wt_crypto < (1-TARGET_DIFF)*TARGET or real_wt_crypto > (1+TARGET_DIFF)*TARGET:
            self.SetHoldings(self.crypto, TARGET)