| Overall Statistics |
|
Total Trades 311 Average Win 0.09% Average Loss -0.07% Compounding Annual Return -20.418% Drawdown 2.200% Expectancy -0.268 Net Profit -1.982% Sharpe Ratio -2.1 Probabilistic Sharpe Ratio 13.161% Loss Rate 67% Win Rate 33% Profit-Loss Ratio 1.23 Alpha -0.047 Beta -0.113 Annual Standard Deviation 0.071 Annual Variance 0.005 Information Ratio -5.753 Tracking Error 0.182 Treynor Ratio 1.313 Total Fees $320.24 Estimated Strategy Capacity $5200000.00 Lowest Capacity Asset PX R735QTJ8XC9X |
from AlgorithmImports import *
class ExtractAlphaTrueBeatsDataAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 1, 1)
self.SetEndDate(2019, 2, 1)
self.SetCash(100000)
self.time = datetime.min
self.AddUniverse(self.MyCoarseFilterFunction)
self.UniverseSettings.Resolution = Resolution.Minute
def MyCoarseFilterFunction(self, coarse):
sortedByDollarVolume = sorted([x for x in coarse if x.HasFundamentalData],
key=lambda x: x.DollarVolume, reverse=True)
selected = [x.Symbol for x in sortedByDollarVolume[:100]]
return selected
def OnData(self, data):
if self.time > self.Time: return
# Retrieve Data
points = data.Get(ExtractAlphaTrueBeats)
if not points: return
trueBeats = {point.Key: trueBeat
for point in points for trueBeat in point.Value}
sortedByTrueBeat = sorted(trueBeats.items(), key=lambda x: x[1].TrueBeat)
longSymbols = [x[0].Underlying for x in sortedByTrueBeat[-10:]]
shortSymbols = [x[0].Underlying for x in sortedByTrueBeat[:10]]
for symbol in self.Portfolio.Keys:
if self.Portfolio[symbol].Invested \
and symbol not in longSymbols \
and symbol not in shortSymbols:
self.Liquidate(symbol)
longTargets = [PortfolioTarget(symbol, 0.05) for symbol in longSymbols]
shortTargets = [PortfolioTarget(symbol, -0.05) for symbol in shortSymbols]
self.SetHoldings(longTargets + shortTargets)
self.time = Expiry.EndOfDay(self.Time)
def OnSecuritiesChanged(self, changes):
for security in changes.AddedSecurities:
# Requesting data
extract_alpha_true_beats_symbol = self.AddData(ExtractAlphaTrueBeats, security.Symbol).Symbol
# Historical Data
history = self.History(extract_alpha_true_beats_symbol, 10, Resolution.Daily)
self.Log(f"We got {len(history)} items from our history request for {security.Symbol} ExtractAlpha True Beats data")