Overall Statistics
Total Trades
170
Average Win
0.96%
Average Loss
-0.09%
Compounding Annual Return
64.079%
Drawdown
29.900%
Expectancy
9.983
Net Profit
119.003%
Sharpe Ratio
1.542
Probabilistic Sharpe Ratio
65.497%
Loss Rate
6%
Win Rate
94%
Profit-Loss Ratio
10.71
Alpha
0.036
Beta
0.375
Annual Standard Deviation
0.309
Annual Variance
0.096
Information Ratio
-1.577
Tracking Error
0.442
Treynor Ratio
1.271
Total Fees
$1198.14
Estimated Strategy Capacity
$67000000.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.Daily).Symbol


    def OnData(self, data):
        if not self.Portfolio[self.crypto].IsLong:
            self.SetHoldings(self.crypto, TARGET)
            
        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)