Overall Statistics
import numpy as np
from clr import AddReference
AddReference("System.Core")
AddReference("System.Collections")
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Algorithm")

from System import *
from System.Collections.Generic import List
from QuantConnect import *
from QuantConnect.Algorithm import QCAlgorithm
from QuantConnect.Data.UniverseSelection import *

### <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 LongShortEquityExposure(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(2013,10, 7)  #Set Start Date
        self.SetEndDate(2013,10,10)    #Set End Date
        self.SetCash(100000)           #Set Strategy Cash
        self.UniverseSettings.Resolution = Resolution.Daily
        self.AddUniverse(self.VolumeFilter)
        
    
    def VolumeFilter(self, coarse):
        
        sortedByDollarVolume = sorted(coarse, key=lambda x: x.DollarVolume, reverse=True)
        self.Debug("{0}: Submitted: {1}".format(self.UtcTime, "volumefiltercreated"))
        return [ x.Symbol for x in sortedByDollarVolume[:1]]
    
    
    def OnData(self, data):
        self.Debug("{0}: Submitted: {1}".format(self.UtcTime, "Ondatacalled"))
        for kvp in self.ActiveSecurities:
            symbol = kvp.Key
            security = kvp.Value
            self.MarketOrder(symbol, 100)
            

        return 

    
    def OnSecuritiesChanged(self, changes):
        self.Debug("{0}: Submitted: {1}".format(self.UtcTime, "Onsecuritiescalled"))
        return 

    def OnOrderEvent(self, OrderEvent):
        self.Debug("ordereventcalled")
        self.Debug(OrderEvent.UtcTime)
        return