Overall Statistics
Total Orders
533
Average Win
0.19%
Average Loss
-0.18%
Compounding Annual Return
-0.183%
Drawdown
5.200%
Expectancy
-0.009
Start Equity
100000
End Equity
99634.34
Net Profit
-0.366%
Sharpe Ratio
-0.968
Sortino Ratio
-0.844
Probabilistic Sharpe Ratio
4.100%
Loss Rate
52%
Win Rate
48%
Profit-Loss Ratio
1.04
Alpha
-0.03
Beta
-0.002
Annual Standard Deviation
0.031
Annual Variance
0.001
Information Ratio
-0.134
Tracking Error
0.166
Treynor Ratio
12.204
Total Fees
$586.05
Estimated Strategy Capacity
$9600000.00
Lowest Capacity Asset
PLTR XIAKBH8EIMHX
Portfolio Turnover
3.44%
from AlgorithmImports import *
from QuantConnect.DataSource import *

class ExtractAlphaTacticalModelAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2021, 10, 10)
        self.set_end_date(2023, 10, 10)
        self.set_cash(100000)
        
        self.last_time = datetime.min
        
        self.add_universe(self.my_coarse_filter_function)
        self.universe_settings.resolution = Resolution.MINUTE
        
    def my_coarse_filter_function(self, coarse: List[CoarseFundamental]) -> List[Symbol]:
        sorted_by_dollar_volume = sorted([x for x in coarse if x.has_fundamental_data and x.price > 4], 
                                key=lambda x: x.dollar_volume, reverse=True)
        selected = [x.symbol for x in sorted_by_dollar_volume[:100]]
        return selected

    def on_data(self, slice: Slice) -> None:
        if self.last_time > self.time: return
    
        # Accessing Data
        points = slice.Get(ExtractAlphaTacticalModel)
        sorted_by_score = sorted([x for x in points.items() if x[1].score], key=lambda x: x[1].score)
        long_symbols = [x[0].underlying for x in sorted_by_score[-10:]]
        short_symbols = [x[0].underlying for x in sorted_by_score[:10]]
        
        for symbol in [x.symbol for x in self.portfolio.Values if x.invested]:
            if symbol not in long_symbols + short_symbols:
                self.liquidate(symbol)
        
        long_targets = [PortfolioTarget(symbol, 0.05) for symbol in long_symbols]
        short_targets = [PortfolioTarget(symbol, -0.05) for symbol in short_symbols]
        self.set_holdings(long_targets + short_targets)
        
        self.last_time = Expiry.END_OF_DAY(self.time)
        
    def on_securities_changed(self, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            # Requesting Data
            extract_alpha_tactical_model_symbol = self.add_data(ExtractAlphaTacticalModel, security.symbol).symbol

            # Historical Data
            history = self.history(extract_alpha_tactical_model_symbol, 60, Resolution.DAILY)
            self.debug(f"We got {len(history)} items from our history request")