The stock price is the result of the trading decisions of many individuals. But what if you could peek into the information gathering process that precedes these decisions?
A recent paper uses Wikipedia page views to predict market changes.
You can try out how different Wikipedia pages affect the market using by clicking “Clone Algorithm” and editing the specified Wikipedia page.
Clone Algorithm
321
Backtest from
to
with
initial capital
Cumulative performance:
Algorithm
Benchmark
Custom data:
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns | 1 Month | 3 Month | 6 Month | 12 Month |
Alpha | 1 Month | 3 Month | 6 Month | 12 Month |
Beta | 1 Month | 3 Month | 6 Month | 12 Month |
Sharpe | 1 Month | 3 Month | 6 Month | 12 Month |
Sortino | 1 Month | 3 Month | 6 Month | 12 Month |
Volatility | 1 Month | 3 Month | 6 Month | 12 Month |
Max Drawdown | 1 Month | 3 Month | 6 Month | 12 Month |
# (c) 2013 Thomas Wiecki, Quantopian Inc. import numpy as np # How many weeks to average over delta_t = 5 def initialize(context): context.article = 'Opportunity cost' fetch_wikipedia(context.article) context.order_size = 10000 context.sec_id = 8554 context.security = sid(8554) # S&P500 context.history = [] context.weekly_history = [] def handle_data(context, data): c = context if c.article not in data: return daily_views = data[c.article]['views'] # Create a window of 5 days. weekly_full = append_window(c.weekly_history, daily_views, 5) if not weekly_full: return # Only trade on the first trading day in the week if data[c.security].dt.weekday() == 0: weekly_views = np.mean(c.weekly_history) # Run a window over delta_t weeks #(+1 because the last one will be the current one we want to ignore). full = append_window(c.history, weekly_views, delta_t+1) if not full: return # Exit any prior positions amount = c.portfolio['positions'][c.sec_id].amount order(c.security, -amount) # Sell if weekly_views are higher than the past weeks if weekly_views > np.mean(c.history[:-1]): order(c.security, -c.order_size) # Buy otherwise. else: order(c.security, c.order_size) def append_window(window, item, length): """Moving window that drops old items longer than length. :Arguments: window : List to append to. item : Item to append. length : Maximum length of the window. :Returns: True if window is full, False if len(windows) < lenght. """ window.append(item) if len(window) < length: return False while len(window) > length: window.pop(0) return True
This backtest was created using an older version of the backtester. Please re-run this backtest to see results using the latest backtester. Learn more about the recent changes.