Overall Statistics
Total Trades
641
Average Win
0.35%
Average Loss
-0.24%
Compounding Annual Return
5.125%
Drawdown
4.100%
Expectancy
0.438
Net Profit
37.091%
Sharpe Ratio
0.886
Probabilistic Sharpe Ratio
34.612%
Loss Rate
42%
Win Rate
58%
Profit-Loss Ratio
1.50
Alpha
0.036
Beta
0
Annual Standard Deviation
0.041
Annual Variance
0.002
Information Ratio
-1.774
Tracking Error
0.621
Treynor Ratio
-124.268
Total Fees
$5707.48
Estimated Strategy Capacity
$2700000.00
class RegressionChannelModel(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2015, 1, 1)
        self.SetCash(100000)
        
        self.SetPortfolioConstruction(InsightWeightingPortfolioConstructionModel())
        self.SetExecution(ImmediateExecutionModel())
        self.SetBrokerageModel(BitfinexBrokerageModel())
        self.UniverseSettings.Resolution = Resolution.Daily
        
        data = self.AddCrypto('ETHUSD', Resolution.Daily, Market.Bitfinex)
        self.symbol = data.Symbol
        
        self.RegressionChannel = self.RC(self.symbol, 20, Resolution.Daily)
        
    def OnData(self, data):
        if not self.symbol in data: return
            
        price = data[self.symbol].Value
        if price == 0: return

        count = 0
        rc = self.RegressionChannel
        delta = (((rc.LinearRegression.Current.Value - price) / rc.LinearRegression.Current.Value) * 100)
        if rc.IsReady:
            if rc.LinearRegression.Current.Value > price and rc.Slope.Current.Value > 0 and delta > 0.5:
                count += 1
                self.Debug(f'Price: {price}, Regression: {rc.LinearRegression.Current.Value}, Delta: {delta}, Slope: {rc.Slope.Current.Value}')
            else:
                self.Liquidate()
                self.EmitInsights(Insight.Price(self.symbol, timedelta(days = 1), InsightDirection.Flat, None, None, None, 1))
            
        weight = (0.1 * count)

        self.EmitInsights(Insight.Price(self.symbol, timedelta(days = 1), InsightDirection.Up, None, None, None, weight))