Overall Statistics |
Total Trades 5 Average Win 4.81% Average Loss 0% Compounding Annual Return 31.478% Drawdown 4.800% Expectancy 0 Net Profit 11.565% Sharpe Ratio 2.47 Probabilistic Sharpe Ratio 75.853% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.013 Beta 0.9 Annual Standard Deviation 0.132 Annual Variance 0.017 Information Ratio -0.857 Tracking Error 0.026 Treynor Ratio 0.361 Total Fees $0.00 Estimated Strategy Capacity $220000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
class TradierEquitiesStochAlpha(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 1, 1) self.SetEndDate(2021, 5, 26) self.SetCash(10000) self.AddEquity("SPY", Resolution.Hour, Market.USA) # This resolution setup determines how often OnData will be called self.SetBrokerageModel(BrokerageName.TradierBrokerage) self.sto = self.STO("SPY", 14, Resolution.Hour) # This resolution setup determines data resolution for STO calculation self.SetWarmUp(30) self.sell_price = None def OnData(self, data): if self.IsWarmingUp or not self.sto.IsReady: return price = self.Securities["SPY"].Close if self.sto.Current.Value < 30 and not self.Portfolio["SPY"].Invested: # self.Debug("Daily SPY STO is < 30") # self.MarketOrder("SPY", 1) # self.Debug(f"Market order was placed for 95% of protfolio in SPY") self.SetHoldings("SPY", 0.95) self.sell_price = (1 + 0.05) * price elif self.sell_price is not None and price >= self.sell_price and self.Portfolio["SPY"].Invested: # self.Debug("SPY sold at a 5% gain or more") # self.MarketOrder("SPY", -self.Portfolio.CashBook["SPY"].Amount) self.SetHoldings("SPY", 0) self.sell_price = None