Overall Statistics
Total Trades
3
Average Win
0%
Average Loss
-27.09%
Compounding Annual Return
3.217%
Drawdown
33.700%
Expectancy
-1
Net Profit
4.920%
Sharpe Ratio
0.207
Probabilistic Sharpe Ratio
12.217%
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.092
Beta
0.727
Annual Standard Deviation
0.198
Annual Variance
0.039
Information Ratio
-1.199
Tracking Error
0.118
Treynor Ratio
0.056
Total Fees
$4.42
Estimated Strategy Capacity
$68000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
from AlgorithmImports import *

class IndexDataAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 1)
        self.SetEndDate(2021, 7, 8)
        self.SetCash(100000)

        # Trade on SPY
        self.spy = self.AddEquity("SPY").Symbol

        # Use indicator for signal; but it cannot be traded
        spx = self.AddIndex("SPX").Symbol
        self.emaFast = self.EMA(spx, 80, Resolution.Daily)
        self.emaSlow = self.EMA(spx, 200, Resolution.Daily)
        self.SetWarmUp(200, Resolution.Daily)

        history = self.History(spx, 60, Resolution.Daily)
        self.Debug(f'We got {len(history.index)} items from our history request')

    def OnData(self, data):
        # Warm up indicators
        if self.IsWarmingUp or not self.emaSlow.IsReady:
            return

        if not self.Portfolio.Invested and self.emaFast > self.emaSlow:
            self.SetHoldings(self.spy, 1)
        elif self.emaFast < self.emaSlow:
            self.Liquidate()