Overall Statistics |
Total Trades 15 Average Win 0.03% Average Loss -0.23% Compounding Annual Return -55.805% Drawdown 0.900% Expectancy -0.629 Net Profit -0.891% Sharpe Ratio -9.509 Probabilistic Sharpe Ratio 0% Loss Rate 67% Win Rate 33% Profit-Loss Ratio 0.11 Alpha -0.368 Beta 0.52 Annual Standard Deviation 0.056 Annual Variance 0.003 Information Ratio -4.204 Tracking Error 0.052 Treynor Ratio -1.016 Total Fees $15.00 Estimated Strategy Capacity $40000000.00 Lowest Capacity Asset ICPT VAO9ZBE1SEAT |
from AlgorithmImports import * #lean project-create --language python "Test" #lean cloud backtest "Test" --push --open #lean backtest Test from datetime import timedelta class Test(QCAlgorithm): def Initialize(self): self.SetCash(100000) # Set Strategy Cash self.SetStartDate(2014, 3, 24) self.SetEndDate(2014,3, 27) self.UniverseSettings.Resolution = Resolution.Daily self.AddUniverse(self.TestFilter) self.AddAlpha(TestAlphaModel(self)) self.SetPortfolioConstruction(InsightWeightingPortfolioConstructionModel(portfolioBias = PortfolioBias.Long)) self.Settings.RebalancePortfolioOnInsightChanges = True self.Settings.RebalancePortfolioOnSecurityChanges = False self.SetExecution(ImmediateExecutionModel()) def TestFilter(self, universe): selected = [] universe = [c for c in universe if c.HasFundamentalData] universe = sorted(universe, key=lambda c: c.DollarVolume, reverse=True)[100:103] #universe = sorted(universe, key=lambda c: c.DollarVolume, reverse=True)[:3] for coarse in universe: selected.append(coarse.Symbol) self.Log(f"[LOG->ADDED] {self.Time}: {coarse.Symbol}") return selected def OnOrderEvent(self, orderEvent: OrderEvent) -> None: order = self.Transactions.GetOrderById(orderEvent.OrderId) if orderEvent.Status == OrderStatus.Filled: self.Log(f"[LOG->ORDER] -> {self.Time}: {order.Type}: {orderEvent}") class TestAlphaModel(AlphaModel): def __init__(self, algo): self.algo = algo def Update(self, algo, slice): insights = [] for symbol in slice.Keys: if slice.ContainsKey(symbol) and slice[symbol] is not None: insights.append(Insight.Price(symbol, timedelta(days=2), InsightDirection.Up, None, None, None, 0.05)) algo.Log(f"[LOG->INSIGHT] -> {algo.Time} {symbol} Up") return insights def OnSecuritiesChanged(self, algo, changes): algo.Log(f"Changes ({algo.Time}):: {changes}")