| Overall Statistics |
|
Total Trades 10 Average Win 0% Average Loss -3.12% Compounding Annual Return -2.140% Drawdown 34.800% Expectancy -1 Net Profit -1.459% Sharpe Ratio 0.254 Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.611 Beta -23.362 Annual Standard Deviation 0.576 Annual Variance 0.332 Information Ratio 0.22 Tracking Error 0.576 Treynor Ratio -0.006 Total Fees $29.70 |
# 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.Daily)
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.sma10vix = self.SMA("VIX", 10, Resolution.Daily)
self.sma20vix = self.SMA("VIX", 50, Resolution.Daily)
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.sma20vix.Current.Value == self.sma10vix.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.sma10vix.Current.Value == self.sma20vix.Current.Value):
self.LimitOrder("SPY", self.CalculateOrderQuantity("SPY", 0.5), (Securities["SPY"].Price - (Securities["SPY"].Price * 0.1)));
self.Debug( str(self.Portfolio["SPXL"].AveragePrice) )
self.Debug( str(self.Portfolio["VIX"].AveragePrice) )
self.Debug( str(self.Portfolio["SPY"].AveragePrice) )