| Overall Statistics |
|
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
#region imports
from AlgorithmImports import *
#endregion
# https://quantpedia.com/Screener/Details/26
from QuantConnect.Data.UniverseSelection import *
import math
import numpy as np
import pandas as pd
import scipy as sp
class BooktoMarketAnomaly(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2018, 7, 1)
self.SetEndDate(2018, 7, 2)
self.SetCash(1000000)
self.UniverseSettings.Resolution = Resolution.Daily
self.sorted_by_bm = None
self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)
# Count the number of months that have passed since the algorithm starts
def CoarseSelectionFunction(self, coarse):
return [x.Symbol for x in coarse if x.HasFundamentalData and x.Price > 5]
def FineSelectionFunction(self, fine):
top_market_cap = sorted(fine, key = lambda x:x.MarketCap, reverse=True)[:int(len([i for i in fine])*0.2)]
self.sorted_by_mc = [i.Symbol for i in top_market_cap]
total_market_cap = np.sum([i.MarketCap for i in top_market_cap])
self.weights = {}
for i in top_market_cap:
self.weights[str(i.Symbol)] = i.MarketCap/total_market_cap
return self.sorted_by_mc
def OnData(self, data):
pass