Overall Statistics |
Total Trades 3 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 0 Tracking Error 0 Treynor Ratio 0 Total Fees $8.92 Estimated Strategy Capacity $9600000.00 Lowest Capacity Asset OXBRU VP83T1ZUHROL |
from AlgorithmImports import * class SelectionData(): #3. Update the constructor to accept a history array def __init__(self, history, algo): self.slow = SimpleMovingAverage(algo.slow) self.fast = SimpleMovingAverage(algo.fast) self.vol = SimpleMovingAverage(algo.vol) #4. Loop over the history data and update the indicators for bar in history.itertuples(): self.fast.Update(bar.Index[1], bar.close) self.slow.Update(bar.Index[1], bar.close) for bar in (history.drop(index=history.index[-1],axis=0,inplace=False)).itertuples(): self.vol.Update(bar.Index[1], bar.volume) def is_ready(self): return self.slow.IsReady and self.fast.IsReady and self.vol.IsReady def update(self, time, price, volume): self.fast.Update(time, price) self.slow.Update(time, price) self.vol.Update(time, volume)
from AlgorithmImports import * from indicator import * class Vol01(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 1, 28) self.SetEndDate(2021, 1, 29) self.SetCash(100000) # Set Strategy Cash self.UniverseSettings.Resolution = Resolution.Daily self.AddUniverse(self.TestFilter) def TestFilter(self, universe): selected = [] universe = [c for c in universe if c.HasFundamentalData] for coarse in universe: symbol = coarse.Symbol if str(symbol).startswith("CRTX ") or \ str(symbol).startswith("CTL ") or \ str(symbol).startswith("OXBRU "): selected.append(symbol) return selected def OnSecuritiesChanged(self, changes): self.changes = changes #1. Liquidate removed securities for security in changes.RemovedSecurities: self.Liquidate(security.Symbol) #2. We want 10% allocation in each security in our universe for security in changes.AddedSecurities: self.SetHoldings(security.Symbol, 0.05)