Created with Highcharts 12.1.2Equity1998200020022004200620082010201220142016201820202022202420260500k1,000k-40-20000.10.2012050010000500M1,000M025M50M49.849.8549.949.95
Overall Statistics
Total Orders
178
Average Win
14.67%
Average Loss
-1.29%
Compounding Annual Return
6.936%
Drawdown
25.500%
Expectancy
1.922
Start Equity
100000
End Equity
620847.83
Net Profit
520.848%
Sharpe Ratio
0.309
Sortino Ratio
0.285
Probabilistic Sharpe Ratio
0.177%
Loss Rate
76%
Win Rate
24%
Profit-Loss Ratio
11.38
Alpha
0.012
Beta
0.369
Annual Standard Deviation
0.096
Annual Variance
0.009
Information Ratio
-0.155
Tracking Error
0.126
Treynor Ratio
0.08
Total Fees
$1273.82
Estimated Strategy Capacity
$510000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
Portfolio Turnover
1.79%
# region imports
from AlgorithmImports import *
# endregion

class CrawlingMagentaTapir(QCAlgorithm):

    def initialize(self):
        self._spy = self.add_equity("SPY")
        self._spy.sma = SimpleMovingAverage(200)
        self.schedule.on(self.date_rules.every_day(self._spy.symbol), self.time_rules.before_market_close(self._spy.symbol, 1), self._rebalance)

    def _rebalance(self):
        if not self._spy.sma.update(self.time, self._spy.price):
            return
        sma = self._spy.sma.current.value
        if self._spy.price > sma and not self._spy.invested:
            self.set_holdings(self._spy.symbol, 1)
        elif self._spy.price < sma and self._spy.invested:
            self.liquidate()
        self.plot('Signal', 'SMA', sma)
        self.plot('Signal', 'Price', self._spy.price)