Overall Statistics
Total Orders
6604
Average Win
4.68%
Average Loss
-3.78%
Compounding Annual Return
18.179%
Drawdown
46.300%
Expectancy
0.149
Start Equity
100000
End Equity
126747.78
Net Profit
26.748%
Sharpe Ratio
0.509
Sortino Ratio
0.478
Probabilistic Sharpe Ratio
23.247%
Loss Rate
49%
Win Rate
51%
Profit-Loss Ratio
1.24
Alpha
0.143
Beta
0.999
Annual Standard Deviation
0.521
Annual Variance
0.271
Information Ratio
0.304
Tracking Error
0.468
Treynor Ratio
0.265
Total Fees
$3838.34
Estimated Strategy Capacity
$170000.00
Lowest Capacity Asset
ACEL X9PDY4DEHQ3P
Portfolio Turnover
20.70%
from AlgorithmImports import *
from QuantConnect.DataSource import *

class QuiverWikipediaDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2019, 1, 1)
        self.set_end_date(2020, 6, 1)
        self.set_cash(100000)

        self.universe_settings.resolution = Resolution.DAILY

        self._universe = self.add_universe(QuiverWikipediaUniverse, self.universe_selection)

    def on_data(self, slice: Slice) -> None:
        points = slice.Get(QuiverWikipedia)
        for point in points.Values:
            symbol = point.symbol.underlying
            
            # Buy if the company's Wikipedia page views have increased over the last week and month
            if point.month_percent_change > 0:
                self.set_holdings(symbol, 1)
            
            # Sell our holdings if the company's Wikipedia page views have not increased over the last month
            else:
                self.set_holdings(symbol, 0)

    def on_securities_changed(self, changes: SecurityChanges) -> None:
        for added in changes.added_securities:
            # Requesting data
            quiver_wiki_symbol = self.add_data(QuiverWikipedia, added.symbol).symbol

            # Historical data
            history = self.history(QuiverWikipedia, quiver_wiki_symbol, 60, Resolution.DAILY)
            self.debug(f"We got {len(history)} items from our history request for Quiver Wikipedia data")

    def universe_selection(self, alt_coarse: List[QuiverWikipediaUniverse]) -> List[Symbol]:
        return [d.Symbol for d in alt_coarse \
        if d.page_views > 100               \
        and d.week_percent_change < 0.2]