Overall Statistics
Total Trades
3
Average Win
0.81%
Average Loss
0%
Compounding Annual Return
108.286%
Drawdown
1.800%
Expectancy
0
Net Profit
1.757%
Sharpe Ratio
4.112
Probabilistic Sharpe Ratio
65.311%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.503
Beta
0.036
Annual Standard Deviation
0.133
Annual Variance
0.018
Information Ratio
-3.51
Tracking Error
0.199
Treynor Ratio
15.203
Total Fees
$7.94
Estimated Strategy Capacity
$63000000.00
Lowest Capacity Asset
AAPL R735QTJ8XC9X
from AlgorithmImports import *

class TestAlgo(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2022, 9, 1)
        self.SetEndDate(2022, 9, 10)

        self.aapl = self.AddEquity("AAPL", Resolution.Minute)
        self.SetPortfolioConstruction(InsightWeightingPortfolioConstructionModel(lambda x: None))

        self.insight_collection = InsightCollection()
    
    def OnData(self, data):
        # Let's emit a signal if no active insight was there
        if not self.insight_collection.GetActiveInsights(self.Time):
            insight = Insight("AAPL", Expiry.EndOfMonth, InsightType.Price, InsightDirection.Up, None, None, None, 0.5)
            self.EmitInsights(insight)
            self.insight_collection.Add(insight)

        # For some reason you want to "hedge" the first signal
        if self.Time == datetime(2022, 9, 2, 11, 0):
            insight = Insight("AAPL", Expiry.EndOfDay, InsightType.Price, InsightDirection.Down, None, None, None, 0.5)
            self.EmitInsights(insight)
            self.insight_collection.Add(insight)
        
        self.insight_collection.RemoveExpiredInsights(self.Time)