Overall Statistics |
Total Trades 125 Average Win 3.82% Average Loss -1.89% Compounding Annual Return 2.182% Drawdown 28.400% Expectancy 0.265 Net Profit 20.678% Sharpe Ratio 0.234 Probabilistic Sharpe Ratio 0.348% Loss Rate 58% Win Rate 42% Profit-Loss Ratio 2.02 Alpha -0.006 Beta 0.275 Annual Standard Deviation 0.077 Annual Variance 0.006 Information Ratio -0.552 Tracking Error 0.125 Treynor Ratio 0.066 Total Fees $231.92 Estimated Strategy Capacity $670000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
from AlgorithmImports import * class FearAlgorithm(QCAlgorithm): def Initialize(self): self.SetCash(100000) self.SetStartDate(2014, 1, 1) self.SetEndDate(2022, 9, 15) # Add a benchmark asset to synchronize the algorithm self.AddEquity("SPY", Resolution.Daily).Symbol # Add VIX as our fear index. self.AddEquity("VXX", Resolution.Daily).Symbol # Get the 30-day EMA of the VIX: self.ema = self.EMA("VXX", 30) # Set warm up so we're instantly trading: self.SetWarmUp(60) def OnData(self, slice): self.Debug("Running algorithm!!") # Make sure all the data we need is in place if self.IsWarmingUp: return if not slice.ContainsKey("VXX"): return if not slice.ContainsKey("SPY"): return # Make some nice plots self.Plot("FEAR", "VXX", self.Securities["VXX"].Price) self.Plot("FEAR", "EMA", self.ema.Current.Value) # Decide when to invest if self.Securities["VXX"].Price < self.ema.Current.Value: if self.Portfolio.Invested: return self.Debug("Investing in SPY...") self.SetHoldings("SPY", 1); else: self.Liquidate() self.Debug("FEAR too great, liquidating...")