Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 35.929% Drawdown 9.700% Expectancy 0 Net Profit 16.805% Sharpe Ratio 2.455 Probabilistic Sharpe Ratio 76.085% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0.996 Annual Standard Deviation 0.169 Annual Variance 0.029 Information Ratio -2.935 Tracking Error 0.001 Treynor Ratio 0.417 Total Fees $1.49 |
from Portfolio.EqualWeightingPortfolioConstructionModel import EqualWeightingPortfolioConstructionModel class CalculatingMagentaGalago(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 8, 11) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.AddAlpha(ConstantAlphaModel(InsightType.Price, InsightDirection.Up, timedelta(minutes = 20), 0.025, None)) symbols = [ Symbol.Create("SPY", SecurityType.Equity, Market.USA) ] self.SetUniverseSelection( ManualUniverseSelectionModel(symbols) ) self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel()) self.SetExecution(LimitOrderExecutionModel()) class LimitOrderExecutionModel(ExecutionModel): # Fill the supplied portfolio targets efficiently def Execute(self, algorithm, targets): for target in targets: open_quantity = sum([x.Quantity for x in algorithm.Transactions.GetOpenOrders(target.Symbol)]) existing = algorithm.Securities[target.Symbol].Holdings.Quantity + open_quantity price = algorithm.Securities[target.Symbol].Price quantity = target.Quantity - existing if quantity != 0: algorithm.LimitOrder(target.Symbol, quantity, price) # Optional: Securities changes event for handling new securities. def OnSecuritiesChanged(self, algorithm, changes): pass