| Overall Statistics |
|
Total Trades 36 Average Win 5.51% Average Loss -2.24% Compounding Annual Return 145.262% Drawdown 22.200% Expectancy 1.118 Net Profit 77.288% Sharpe Ratio 2.827 Probabilistic Sharpe Ratio 83.161% Loss Rate 39% Win Rate 61% Profit-Loss Ratio 2.47 Alpha 0.526 Beta 2.182 Annual Standard Deviation 0.345 Annual Variance 0.119 Information Ratio 2.803 Tracking Error 0.274 Treynor Ratio 0.447 Total Fees $234.47 Estimated Strategy Capacity $46000000.00 Lowest Capacity Asset MSFT R735QTJ8XC9X |
from AlgorithmImports import *
class SECReport8KAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 1, 1)
self.SetEndDate(2019, 8, 21)
self.SetCash(100000)
self.mappings = {}
self.UniverseSettings.Resolution = Resolution.Minute
self.AddUniverse(self.CoarseSelector)
# Request underlying equity data.
ibm = self.AddEquity("IBM", Resolution.Minute).Symbol
# Add news data for the underlying IBM asset
earningsFiling = self.AddData(SECReport10Q, ibm, Resolution.Daily).Symbol
# Request 120 days of history with the SECReport10Q IBM custom data Symbol
history = self.History(SECReport10Q, earningsFiling, 120, Resolution.Daily)
# Count the number of items we get from our history request
self.Debug(f"We got {len(history)} items from our history request")
def CoarseSelector(self, coarse):
coarse = sorted([cf for cf in coarse if cf.HasFundamentalData],
key=lambda cf: cf.DollarVolume, reverse=True)[:10]
return [cf.Symbol for cf in coarse]
def OnData(self, data):
# Store the symbols we want to long in a list
# so that we can have an equal-weighted portfolio
longEquitySymbols = []
# Get all SEC data and loop over it
for report in data.Get(SECReport8K).Values:
# Get the length of all contents contained within the report
reportTextLength = sum([len(i.Text) for i in report.Report.Documents])
if reportTextLength > 20000:
longEquitySymbols.append(report.Symbol.Underlying)
for equitySymbol in longEquitySymbols:
self.SetHoldings(equitySymbol, 1.0 / len(longEquitySymbols))
def OnSecuritiesChanged(self, changes):
for symbol in [s.Symbol for s in changes.AddedSecurities]:
self.mappings[symbol] = self.AddData(SECReport8K, symbol).Symbol
for symbol in [s.Symbol for s in changes.RemovedSecurities]:
# If removed from the universe, liquidate and remove the custom data from the algorithm
self.Liquidate(symbol)
reportSymbol = self.mappings.pop(symbol, None)
if reportSymbol:
self.RemoveSecurity(reportSymbol)