| Overall Statistics |
|
Total Trades 68 Average Win 3.70% Average Loss -2.15% Compounding Annual Return 12.552% Drawdown 29.600% Expectancy 0.182 Net Profit 18.270% Sharpe Ratio 0.457 Probabilistic Sharpe Ratio 20.539% Loss Rate 57% Win Rate 43% Profit-Loss Ratio 1.72 Alpha 0.212 Beta -0.569 Annual Standard Deviation 0.281 Annual Variance 0.079 Information Ratio -0.04 Tracking Error 0.437 Treynor Ratio -0.226 Total Fees $676.76 Estimated Strategy Capacity $320000000.00 Lowest Capacity Asset AAPL R735QTJ8XC9X |
from AlgorithmImports import *
class QuiverCongressDataAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 1, 1)
self.SetEndDate(2020, 6, 1)
self.SetCash(100000)
# Requesting data
aapl = self.AddEquity("AAPL", Resolution.Daily).Symbol
quiver_congress_symbol = self.AddData(QuiverCongress, aapl).Symbol
# Historical data
history = self.History(QuiverCongress, quiver_congress_symbol, 60, Resolution.Daily)
self.Debug(f"We got {len(history)} items from our history request");
def OnData(self, data):
points = data.Get(QuiverCongress)
# Determine net direction of Congress trades for each security
net_quantity_by_symbol = {}
for point in points.Values:
symbol = point.Symbol.Underlying
if symbol not in net_quantity_by_symbol:
net_quantity_by_symbol[symbol] = 0
net_quantity_by_symbol[symbol] += (1 if point.Transaction == OrderDirection.Buy else -1) * point.Amount
for symbol, net_quantity in net_quantity_by_symbol.items():
# Buy when Congress members have bought
if net_quantity > 0:
self.SetHoldings(symbol, 1)
# Short sell when Congress members have sold
else:
self.SetHoldings(symbol, -1)