Overall Statistics
Total Trades
492
Average Win
0.75%
Average Loss
-0.38%
Compounding Annual Return
-80.897%
Drawdown
66.300%
Expectancy
-0.167
Net Profit
-60.181%
Sharpe Ratio
-0.725
Probabilistic Sharpe Ratio
3.196%
Loss Rate
72%
Win Rate
28%
Profit-Loss Ratio
1.97
Alpha
-0.448
Beta
1.672
Annual Standard Deviation
0.74
Annual Variance
0.548
Information Ratio
-0.72
Tracking Error
0.671
Treynor Ratio
-0.321
Total Fees
$0.00
Estimated Strategy Capacity
$480000.00
Lowest Capacity Asset
BTCUSD XJ
from QuantConnect.Indicators import *
from AlgorithmImports import *


class BollingerMomentum(QCAlgorithm):

    def Initialize(self):

        self.SetStartDate(2022, 6, 1) 
        self.SetCash("BTC",100) 
        self.ticker="BTCUSD"
        self.symbol=self.AddCrypto(self.ticker, Resolution.Minute).Symbol
        self.per_order_proportion=0.5
        period_BB = 25
        std=2
        self.Bolband = self.BB(self.ticker, period_BB, std, MovingAverageType.Simple, Resolution.Hour)
        self.SetRiskManagement(MaximumDrawdownPercentPerSecurity(0.01))
        self.SetWarmUp(period_BB)
    def OnData(self, data):
        if self.IsWarmingUp != False:
            return
        
        holdings = self.Portfolio[self.ticker].Quantity
        price = self.Securities[self.ticker].Close
        quantity = self.CalculateOrderQuantity(self.ticker,self.per_order_proportion)
        
        if holdings <= 0:
            if price <= self.Bolband.LowerBand.Current.Value:
                self.MarketOrder(self.ticker, quantity*1)
        if holdings > 0:
            if price >= self.Bolband.UpperBand.Current.Value:
                self.LiquidateAll()
                        
    def LiquidateAll(self):
        self.Liquidate()
        self.Transactions.CancelOpenOrders(self.ticker)