Overall Statistics |
Total Orders 10395 Average Win 0.49% Average Loss -0.19% Compounding Annual Return 6.440% Drawdown 20.300% Expectancy 0.101 Start Equity 100000 End Equity 253496.59 Net Profit 153.497% Sharpe Ratio 0.336 Sortino Ratio 0.398 Probabilistic Sharpe Ratio 1.065% Loss Rate 69% Win Rate 31% Profit-Loss Ratio 2.50 Alpha -0.01 Beta 0.47 Annual Standard Deviation 0.095 Annual Variance 0.009 Information Ratio -0.563 Tracking Error 0.101 Treynor Ratio 0.068 Total Fees $66686.71 Estimated Strategy Capacity $1200000.00 Lowest Capacity Asset SHY SGNKIKYGE9NP Portfolio Turnover 190.49% |
# region imports from AlgorithmImports import * # endregion class KellyCriterionSMACrossoverAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2010, 1, 1) # Add the risky and risk-free assets. self._risk_asset = self.add_equity("SPY", Resolution.HOUR) self._rf_asset = self.add_equity('SHY', Resolution.HOUR) # Add some strategy-specific indicators/variables. self._risk_asset.short_sma = self.sma(self._risk_asset.symbol, 1) self._risk_asset.long_sma = self.sma(self._risk_asset.symbol, 6) # Add a warm-up period so we some historical performance of the strategy # once we start trading. self.set_warm_up(timedelta(365)) def on_data(self, data: Slice): # Wait until the market is open. if not data.bars or not self.is_market_open(self._risk_asset.symbol) or self.is_warming_up: return if not self._risk_asset.holdings.is_long and self._risk_asset.short_sma > self._risk_asset.long_sma: self.set_holdings([PortfolioTarget(self._risk_asset.symbol, 1)], True) elif self._risk_asset.holdings.is_long and self._risk_asset.short_sma < self._risk_asset.long_sma: self.set_holdings([PortfolioTarget(self._rf_asset.symbol, 1)], True)