| Overall Statistics |
|
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -229.947 Tracking Error 0.072 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
class VirtualBrownGull(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2022, 2, 7) # Set Start Date
self.SetEndDate(2022, 2, 9)
self.SetCash(100000)
self.UniverseSettings.Resolution = Resolution.Daily
self.AddUniverse(self.CoarseSelectionFunction)
#self.selected = None
#smavolumemin = 1000000
#self.smavolumemin = smavolumemin
self.averages = { }
def CoarseSelectionFunction(self, coarse): # was originally self, universe
selected = []
sortedbyPrice = sorted(coarse, key=lambda c: c.Price, reverse=True)
filteredbyPrice = [c for c in sortedbyPrice if c.Price > 2 and c.Price < 10]
for coarse in filteredbyPrice:
symbol = coarse.Symbol
if symbol not in self.averages:
history = self.History(symbol, 30, Resolution.Daily)
self.averages[symbol] = SelectionData(history)
self.averages[symbol].update(self.Time, coarse.Volume)
if self.averages[symbol].is_ready():
if self.averages[symbol].thirtysma.Current.Value > 1000000:
selected.append(symbol)
return selected
def OnSecuritiesChanged(self, changes):
for added in changes.AddedSecurities:
self.Log(f"Added {added.Symbol}")
for removed in changes.RemovedSecurities:
self.Log(f"Removed {removed.Symbol}")
return
class SelectionData(): # this changes
def __init__(self, history):
self.thirtysma = SimpleMovingAverage(30)
for bar in history.itertuples():
self.thirtysma.Update(bar.Index[1], bar.volume)
def is_ready(self):
return self.thirtysma.IsReady
def update(self, time, volume):
#self.volume = volume
self.thirtysma.Update(time, volume)