| Overall Statistics |
|
Total Trades 171 Average Win 0.42% Average Loss -0.40% Compounding Annual Return -0.191% Drawdown 7.200% Expectancy -0.008 Net Profit -0.388% Sharpe Ratio -0.012 Probabilistic Sharpe Ratio 4.119% Loss Rate 52% Win Rate 48% Profit-Loss Ratio 1.06 Alpha -0.008 Beta 0.21 Annual Standard Deviation 0.041 Annual Variance 0.002 Information Ratio -0.595 Tracking Error 0.061 Treynor Ratio -0.002 Total Fees $491.94 Estimated Strategy Capacity $170000.00 Lowest Capacity Asset MANU V8Z89IPL1MCL |
from AlgorithmImports import *
class QuiverTwitterFollowersDataAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 5, 1)
self.SetEndDate(2020, 7, 1)
self.SetCash(100000)
self.UniverseSettings.Resolution = Resolution.Daily
# add a custom universe data source (defaults to usa-equity)
self.AddUniverse(QuiverQuantTwitterFollowersUniverse, "QuiverQuantTwitterFollowersUniverse", Resolution.Daily, self.UniverseSelection)
def UniverseSelection(self, alt_coarse):
for datum in alt_coarse:
self.Log(f"{datum.Symbol},{datum.Followers},{datum.DayPercentChange},{datum.WeekPercentChange}")
# define our selection criteria
return [d.Symbol for d in alt_coarse \
if d.Followers > 200000 \
and d.WeekPercentChange > 0]
def OnData(self, data):
points = data.Get(QuiverQuantTwitterFollowers)
# Get all (symbol, followers) pair
number = [(point.Symbol.Underlying, point.Followers) for point in points.Values]
# sort the list to get top 5 most followed companies
sort_number = sorted(number, key=lambda x: x[1], reverse=True)[:5]
selected_symbols = [x[0] for x in sort_number]
# We liquidate the stocks that fall out of top 5 most followed companies if invested previously
for symbol in self.Portfolio.Keys:
if self.Portfolio[symbol].Invested and symbol not in selected_symbols:
self.Liquidate(symbol)
# set equal holdings for the 5 selected
for symbol in selected_symbols:
self.SetHoldings(symbol, 1/len(selected_symbols))
def OnSecuritiesChanged(self, changes):
for added in changes.AddedSecurities:
symbol = added.Symbol
self.AddData(QuiverQuantTwitterFollowers, symbol).Symbol
# Historical data
history = self.History(QuiverQuantTwitterFollowers, symbol, 60, Resolution.Daily)
self.Debug(f"We got {len(history.index)} items from our history request")