Hi, I'm playing around with deciles and I'd like some help/advice on how to use them. I'm pretty new to Quantopian still. If anyone has some example code, that would also be great.
1) How do I use them?
I'm trying something like this:
class MarketCap(CustomFactor):
# Pre-declare inputs and window_length
inputs = [USEquityPricing.close, morningstar.valuation.shares_outstanding]
window_length = 1
# Compute market cap value
def compute(self, today, assets, out, close, shares):
out[:] = close[-1] * shares[-1]
def initialize(context):
pipe = Pipeline()
mkt_cap = MarketCap()
# Heres the call
top_40_percent = MarketCap.deciles(4)
# This also doesn't work
top_40_percent = MarketCap.deciles.top(4)
attach_pipeline(top_40_percent, 'top_market_cap_stocks')
1) How do I get them?
I've got 2 values I'm calculating on my universe of stocks. To combine them, the idea is to take their percentile for each individual measure and then add them -- the combined rank then becomes their new score, and I re-sort; eventually investing in the stocks with the highest combined score. Any advice?
Thanks