Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
0.053%
Drawdown
0.000%
Expectancy
0
Net Profit
0.053%
Sharpe Ratio
1.947
Probabilistic Sharpe Ratio
86.642%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0.001
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-2.102
Tracking Error
0.104
Treynor Ratio
0.278
Total Fees
$1.00
Estimated Strategy Capacity
$110000000000.00
Lowest Capacity Asset
MSFT R735QTJ8XC9X
from AlgorithmImports import *

class ExtractAlphaEstimizeAlgorithm(QCAlgorithm):
	
    def Initialize(self) -> None:
        self.SetStartDate(2018, 12, 29)
        self.SetEndDate(2020, 1, 1)
        self.SetCash(100000)

        self.aapl = self.AddEquity("MSFT", Resolution.Daily).Symbol
        estimize_consensus_symbol = self.AddData(EstimizeConsensus, self.aapl).Symbol
        estimize_estimate_symbol = self.AddData(EstimizeEstimate, self.aapl).Symbol
        estimize_release_symbol = self.AddData(EstimizeRelease, self.aapl).Symbol
        
        
    def OnData(self, slice: Slice) -> None:
        
        self.vale = []
        release = slice.Get(EstimizeRelease)
        for symbol, value in release.items():
            self.Log(f"""Symbol: {symbol} - Time: {self.Time}, Release Date: {value.ReleaseDate}""")
            self.Debug("quantity: " + str(len(release.items())) +"- Time :" + str(self.Time))
            #val = (value.ReleaseDate - timedelta(days=30))
            #self.vale.append(val)
            #self.Log(self.vale)
            if self.Time >= (value.ReleaseDate - timedelta(days=30)) and self.Time < value.ReleaseDate:
                if self.Portfolio.Invested: 
                    return
                elif not self.Portfolio.Invested: 
                    self.Log("Bought" +str(self.Time) )
                    self.Buy(self.aapl, 1) 

            if self.Time < (value.ReleaseDate - timedelta(days=30)) and self.Time > value.ReleaseDate:
                if not self.Portfolio.Invested:
                    return
                elif self.Portfolio.Invested: 
                    self.Log("Sold" +str(self.Time) )
                    self.Sell(self.aapl, 1)