Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
# Find more symbols here: http://quantconnect.com/data import numpy as np ### <summary> ### Basic template algorithm simply initializes the date range and cash. This is a skeleton ### framework you can use for designing an algorithm. ### </summary> class FischerBlack(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' def Initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.SetStartDate(2018, 1, 1) #Set Start Date self.SetEndDate(2018, 9, 5) #Set End Date self.SetCash(100000) #Set Strategy Cash self.etf = self.AddEquity("SPXL", Resolution.Daily) self.etf.SetDataNormalizationMode(DataNormalizationMode.SplitAdjusted) self.vix = self.AddEquity("VIX", Resolution.Minute) self.vix.SetDataNormalizationMode(DataNormalizationMode.Adjusted) #self.spy = self.AddEquity("SPY", Resolution.Daily) #self.spy.SetDataNormalizationMode(DataNormalizationMode.Adjusted) self.sma50etf = self.SMA("SPXL", 50, Resolution.Daily) self.sma20etf = self.SMA("SPXL", 20, Resolution.Daily) self.sma50vix = self.SMA("VIX", 50, Resolution.Minute) self.Debug("numpy test >>> print numpy.pi: " + str(np.pi)) def OnData(self, data): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: data: Slice object keyed by symbol containing the stock data''' if (self.vix.Price < self.sma50vix.Current.Value): if (self.sma20etf.Current.Value > self.sma50etf.Current.Value): self.MarketOrder("SPXL", self.CalculateOrderQuantity("SPXL", 1)); elif (self.sma50etf.Current.Value < self.sma20etf.Current.Value): self.MarketOrder("SPXL", -(self.CalculateOrderQuantity("SPXL", 0.25))); elif (self.vix.Price > self.sma50vix.Current.Value): self.Liquidate(); #self.LimitOrder("SPY", self.CalculateOrderQuantity("SPY", 0.5), (Securities["SPY"].Price - (Securities["SPY"].Price * 0.1))); else: self.Log("Values are equal, expected greater than or less than!"); self.Debug( str(self.Portfolio["SPXL"].AveragePrice) ) self.Debug( str(self.Portfolio["VIX"].AveragePrice) ) #self.Debug( str(self.Portfolio["SPY"].AveragePrice) )