Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
-0.908%
Drawdown
0.000%
Expectancy
0
Net Profit
-0.010%
Sharpe Ratio
-7.937
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.006
Beta
-0.913
Annual Standard Deviation
0.001
Annual Variance
0
Information Ratio
-14.025
Tracking Error
0.001
Treynor Ratio
0.007
Total Fees
$1.00
import numpy as np

class MyAlgorithm(QCAlgorithm):

    def Initialize(self):

        self.SetStartDate(2018,6,15)    #Set Start Date
        self.SetEndDate(2018,6,18)      #Set End Date
        self.SetCash(100000)            # Account value

        self.AddEquity("SPY", Resolution.Second)

        self.AddUniverse(self.CoarseSelectionFunction)

        self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 10), self.TradeBeforeMarketClose)

    def CoarseSelectionFunction(self, coarse):

        # price > 5 and volume > 500k and sector data available
        selected = [x for x in coarse if (float(x.Price) >= 5 and x.Volume > 5000000) ]

        # this is our universe
        self.Debug("selected:" + str(len(selected)))

        # subscribe to these stocks, add list of symbols to self
        self.MySymbols = []
        for x in selected:
            self.MySymbols.append(self.AddEquity(x.Symbol.Value, Resolution.Minute).Symbol)

        # return the list of symbols for consistency with "fine", but they are already saved in self.MySymbols[]
        return [ x.Symbol for x in selected ]

    # trade routine
    def TradeBeforeMarketClose(self):

        try:
            self.Debug("Selected symbols in universe: " + str(len(self.MySymbols)))
        except:
            return

        self.MarketOrder("SPY", 100)

        return

    # order notifications
    def OnOrderEvent(self, fill):
        order = self.Transactions.GetOrderById(fill.OrderId)
        self.Debug("{0} - {1}:TEST: {2}".format(self.Time, order.Type, fill))