Overall Statistics
Total Trades
52
Average Win
0.05%
Average Loss
-0.01%
Compounding Annual Return
0.940%
Drawdown
0.200%
Expectancy
6.348
Net Profit
0.992%
Sharpe Ratio
2.198
Probabilistic Sharpe Ratio
95.948%
Loss Rate
19%
Win Rate
81%
Profit-Loss Ratio
8.10
Alpha
0.006
Beta
0
Annual Standard Deviation
0.003
Annual Variance
0
Information Ratio
-0.66
Tracking Error
0.124
Treynor Ratio
22.771
Total Fees
$0.00
Estimated Strategy Capacity
$380000.00
Lowest Capacity Asset
USDTUSD 2MN
#if self.entryPrice * 0.01 <= usdt_price:
# --------------------------
CRYPTO = "USDTUSD"; BAR = 5; 
# --------------------------

class CryptoConsolidator(QCAlgorithm):
     
    def Initialize(self):
        self.SetStartDate(2021, 4, 1)
        self.SetEndDate(2022,  4, 20)
        self.SetCash(1000) 
        self.crypto = self.AddCrypto(CRYPTO, Resolution.Minute,Market.FTX).Symbol
        self.Consolidate(self.crypto, timedelta(minutes = BAR), self.BarHandler)
        self.entryPrice = 0
        self.nextEntryTime = self.Time
        self.period = timedelta(minutes = BAR) 


         
    def BarHandler(self, consolidated):
        self.Plot("USDTUSD", self.crypto, self.Securities[self.crypto].Price)
        
    def OnData(self, data):
        
        hist = self.History(self.crypto , timedelta(BAR), Resolution.Hour)#365
        low = min(hist["low"])
        high = max(hist["high"])
        
        
        if self.IsWarmingUp or not (self.nextEntryTime <= self.Time): return
        price = float(self.Securities[self.crypto].Close)
        
        if not self.Portfolio[self.crypto].Invested:
            if  price  < low :
                self.SetHoldings(self.crypto, 1.00)
                #self.entryPrice = price

        elif self.Portfolio[self.crypto].Invested:
            if  price >= high :
                self.Liquidate(self.crypto, "Take Profit")
                #self.entryPrice = price

        self.nextEntryTime = self.Time + self.period