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 12.398 Tracking Error 0.078 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
class RetrospectiveTanButterfly(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 9, 16) # Set Start Date self.SetEndDate(2021, 9, 20) self.SetCash(100000) # Set Strategy Cash self.symbolData = {} tickers = ["SPY", "QQQ"] for ticker in tickers: symbol = self.AddEquity(ticker, Resolution.Tick).Symbol self.symbolData[symbol] = SymbolData() self.symbolData[symbol].bidPrice = self.Securities[symbol].BidPrice self.symbolData[symbol].askPrice = self.Securities[symbol].AskPrice def OnData(self, data): for symbol, symbolData in self.symbolData.items(): if not data.Ticks.ContainsKey(symbol): continue ticks = data.Ticks[symbol] for tick in ticks: if tick.TickType == TickType.Quote: symbolData.bidPrice = tick.BidPrice if tick.BidPrice != 0 else symbolData.bidPrice symbolData.askPrice = tick.AskPrice if tick.AskPrice != 0 else symbolData.askPrice elif tick.TickType == TickType.Trade: if tick.Price - symbolData.bidPrice > symbolData.askPrice - tick.Price: symbolData.sellVolume += tick.Quantity else: symbolData.buyVolume += tick.Quantity def OnEndOfDay(self, symbol): symbolData = self.symbolData[symbol] self.Debug(f"{symbol.Value}'s buy volume is {symbolData.buyVolume} and sell volume is {symbolData.sellVolume} for today") symbolData.Clear() class SymbolData: def __init__(self): self.buyVolume = 0 self.sellVolume = 0 self.bidPrice = 0 self.askPrice = 0 def Clear(self): self.buyVolume = 0 self.sellVolume = 0