Overall Statistics |
Total Trades 3 Average Win 0% Average Loss -6.90% Compounding Annual Return -6.031% Drawdown 11.500% Expectancy -1 Net Profit -5.501% Sharpe Ratio -0.296 Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.323 Beta -18.634 Annual Standard Deviation 0.164 Annual Variance 0.027 Information Ratio -0.417 Tracking Error 0.164 Treynor Ratio 0.003 Total Fees $3.77 |
import numpy as np from datetime import datetime import pandas as pd class VolTrading(QCAlgorithm): def Initialize(self): self.SetStartDate(2018,1,1) #Set Start Date #self.SetEndDate(2018,1,1) #Set End Date self.SetCash(10000) #Set Strategy Cash self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol self.vixy = self.AddEquity("VIXY", Resolution.Minute).Symbol self.SetWarmUp(440) self.previous = None self.position = None def OnData(self, data): if data.Bars.ContainsKey("SPY") or data.Bars.ContainsKey("VIXY"): SPercent = np.log(float(self.Securities[self.spy].Price/data[self.spy].Open)) VPercent = np.log(float(self.Securities[self.vixy].Price/data[self.vixy].Open)) if self.IsWarmingUp: return if SPercent <= -.005: if self.position == None: self.SetHoldings("VIXY", 1) elif self.position == "SPY": self.Liquidate("SPY") self.SetHoldings("VIXY", 1) self.position = "VIXY" if SPercent >= .005: if self.position == None: self.SetHoldings("SPY", 1) elif self.position == "VIXY": self.Liquidate("VIXY") self.SetHoldings("SPY", 1) self.position = "SPY"