| 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 -0.502 Tracking Error 0.154 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
class TradierEquitiesStochAlpha(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2021, 1, 1)
self.SetEndDate(2021, 2, 1)
self.SetCash(1000)
self.AddEquity("SPY", Resolution.Daily, Market.USA)
self.SetBrokerageModel(BrokerageName.TradierBrokerage)
self.sto = self.STO("SPY", 14)
self.sell_price = None
def OnData(self, data):
if not self.sto.IsReady:
return
price = self.Securities["SPY"].Close
if self.sto.Current.Value < 30 and self.Portfolio == 0:
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.sell_price = (1 + 0.05) * price
if self.sell_price is not None and price >= self.sell_price and self.sto.Current.Value > 80:
self.Debug("SPY sold at a 5% gain or more")
self.MarketOrder("SPY", -self.Portfolio.CashBook["SPY"].Amount)
self.sell_price = None
#if self.sell_price is not None and price <= self.sell_price * .95:
#self.Debug("Price dropped 5%")
#self.MarketOrder(self.symbol, -self.Portfolio.CashBook["ETH"].Amount)
#self.sell_price = None