Overall Statistics
Total Trades
1003
Average Win
10.71%
Average Loss
-0.24%
Compounding Annual Return
21.196%
Drawdown
41.200%
Expectancy
1.674
Net Profit
729.842%
Sharpe Ratio
0.857
Probabilistic Sharpe Ratio
20.883%
Loss Rate
94%
Win Rate
6%
Profit-Loss Ratio
45.19
Alpha
0.09
Beta
0.688
Annual Standard Deviation
0.19
Annual Variance
0.036
Information Ratio
0.342
Tracking Error
0.169
Treynor Ratio
0.237
Total Fees
$54570.59
Estimated Strategy Capacity
$4800000.00
Lowest Capacity Asset
AAPL R735QTJ8XC9X
# region imports
from AlgorithmImports import *
# endregion

class AdaptableMagentaCaterpillar(QCAlgorithm):


    def Initialize(self):
        self.SetStartDate(2010, 1, 1)
        self.SetEndDate(2021, 1, 1)
        startingValue = 100000
        self.SetCash(startingValue)
        self.sma = SimpleMovingAverage("SMA1", 126)
        self.symbol = self.AddEquity("AAPL").Symbol
        self.RegisterIndicator(self.symbol, self.sma, Resolution.Daily)

    def OnData(self, data):
        if self.IsWarmingUp: return
   
        price = self.Securities[self.symbol].Price
        if price > 0.0:
            if price > self.sma.Current.Price:
                if not self.Portfolio[self.symbol].IsLong:
                    self.SetHoldings(self.symbol, 0.98)
            elif price <= self.sma.Current.Price:
                if not self.Portfolio[self.symbol].IsShort:
                    self.Liquidate(self.symbol)