| Overall Statistics |
|
Total Trades 46 Average Win 2.25% Average Loss -2.68% Compounding Annual Return 2.270% Drawdown 12.400% Expectancy 0.200 Net Profit 11.889% Sharpe Ratio 0.318 Probabilistic Sharpe Ratio 3.052% Loss Rate 35% Win Rate 65% Profit-Loss Ratio 0.84 Alpha 0.011 Beta 0.051 Annual Standard Deviation 0.054 Annual Variance 0.003 Information Ratio -0.623 Tracking Error 0.158 Treynor Ratio 0.336 Total Fees $524.82 Estimated Strategy Capacity $64000000.00 Lowest Capacity Asset AAPL R735QTJ8XC9X |
from AlgorithmImports import *
class CorporateBuybacksDataAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2016, 1, 1)
self.SetEndDate(2021, 1, 1)
self.SetCash(100000)
self.aapl = self.AddEquity("AAPL", Resolution.Minute).Symbol
# Requesting data
self.smart_insider_intention = self.AddData(SmartInsiderIntention, self.aapl).Symbol
self.smart_insider_transaction = self.AddData(SmartInsiderTransaction, self.aapl).Symbol
# Historical data
history = self.History(self.smart_insider_intention, 365, Resolution.Daily)
self.Debug(f"We got {len(history)} items from our history request for intentions")
history = self.History(self.smart_insider_transaction, 365, Resolution.Daily)
self.Debug(f"We got {len(history)} items from our history request for transactions")
def OnData(self, data):
# Buy Apple whenever we receive a buyback intention or transaction notification
if data.ContainsKey(self.smart_insider_intention) or data.ContainsKey(self.smart_insider_transaction):
self.SetHoldings(self.aapl, 1)
self.entry_time = self.Time
# Liquidate holdings 3 days after the latest entry
if self.Portfolio.Invested and self.Time >= self.entry_time + timedelta(days=3):
self.Liquidate()