Overall Statistics
Total Trades
14
Average Win
0.91%
Average Loss
0%
Compounding Annual Return
58.422%
Drawdown
34.700%
Expectancy
0
Net Profit
37.037%
Sharpe Ratio
1.102
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
1.227
Beta
-30.668
Annual Standard Deviation
0.559
Annual Variance
0.312
Information Ratio
1.066
Tracking Error
0.559
Treynor Ratio
-0.02
Total Fees
$38.30
# 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("VIXH", 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)
        self.sma20etf = self.SMA("SPXL", 20)
        
        self.sma10vix = self.SMA("VIXH", 10)
        self.sma20vix = self.SMA("VIXH", 50)
        
        self.SetWarmUp(50)
        
    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), (float(self.Securities["SPY"].Price) - (float(self.Securities["SPY"].Price) * 0.1)));
    
        self.Debug( str(self.Portfolio["SPXL"].AveragePrice) )
        self.Debug( str(self.Portfolio["VIXH"].AveragePrice) )
        self.Debug( str(self.Portfolio["SPY"].AveragePrice) )