Overall Statistics
Total Trades
2
Average Win
0%
Average Loss
0%
Compounding Annual Return
15.817%
Drawdown
0.300%
Expectancy
0
Net Profit
0.114%
Sharpe Ratio
2.972
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
6.959
Annual Standard Deviation
0.024
Annual Variance
0.001
Information Ratio
2.551
Tracking Error
0.024
Treynor Ratio
0.01
Total Fees
$2.00
from clr import AddReference
AddReference("System")
AddReference("NodaTime")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Indicators")
AddReference("QuantConnect.Common")

from System import *
from NodaTime import DateTimeZone
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Brokerages import *
from QuantConnect.Data.Market import *

class BasicTemplateAlgorithm(QCAlgorithm):

    def Initialize(self):
        # Set the cash we'd like to use for our backtest
        # This is ignored in live trading
        self.SetCash(37000)

        # Set benchmark
        # self.SetBenchmark("XIV")

        # Start and end dates for the backtest.
        # These are ignored in live trading.
        self.SetStartDate(2018,1,8)
        self.SetEndDate(2018,1,10)

        #Assets predetermined
        self.vxx = self.AddEquity("UVXY", Resolution.Hour).Symbol
        self.xiv = self.AddEquity("XIV", Resolution.Hour, Market.USA, True, 1, True)
        self.spy = self.AddEquity("SPY", Resolution.Hour).Symbol

        self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.At(16, 15), self.buyAtTime)

        # self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.At(8, 30), self.buyAtTime)

    def buyAtTime(self):
        # if self.Portfolio[self.xiv.Symbol].Quantity > 0:
        self.Debug("{0} before and holding {1}".format(str(self.Time), self.Portfolio[self.xiv.Symbol].Quantity))
        self.MarketOrder(self.xiv.Symbol, 20)
        # if self.Portfolio[self.xiv.Symbol].Quantity > 0:
        self.Debug("{0} after and holding {1}".format(str(self.Time), self.Portfolio[self.xiv.Symbol].Quantity))

    def OnData(self, slice):
        self.Debug("open orders {0} at {1}".format(self.Transactions.GetOpenOrders(self.xiv.Symbol), str(self.Time)))