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 -4.569 Tracking Error 0.118 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
class RetrospectiveTanButterfly(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 8, 24) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.symbolData = {} self.bidPrice = {} self.askPrice = {} tickers = ["SPY", "QQQ"] for ticker in tickers: symbol = self.AddEquity(ticker, Resolution.Tick).Symbol self.symbolData[symbol] = SymbolData() self.bidPrice[symbol] = self.Securities[symbol].BidPrice self.askPrice[symbol] = 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: self.bidPrice[symbol] = tick.BidPrice self.askPrice[symbol] = tick.AskPrice elif tick.TickType == TickType.Trade: if tick.Price - self.bidPrice[symbol] > self.askPrice[symbol] - 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 def Clear(self): self.buyVolume = 0 self.sellVolume = 0