Hi wonderful Quantopians!
I have a pretty straightforward model. It uses a ranking filter of fundamentals and AVG Dollar Volume strategy when purchasing US stocks. The model uses a bucket of quality assets available for purchase once every week.
I want to test my model using only a list of a certain amount of specific stocks(For example 2-10 different stocks). I would need to remove the filters I have in my model just in case. However, I cannot seem to figure out the simple code needed to make my model purchase from only a list instead or such a large universe.
I keep coming across errors in the IDE, would love some guidance on this one.
def initialize(context):
# Universe Selection
market = (
MarketCap().percentile_between(MIN_Market_Cap_Percentile, 100)
& Sector().notnull()
& builtin.USEquityPricing.close.latest.notnull()
& (builtin.USEquityPricing.volume.latest > 0)
)
monthly_top_volume = (
AverageDollarVolume(window_length=LiquidityHistory)
.top(MarketSize, mask=market)
.downsample(Market_Data_Frequency)
)
universe = monthly_top_volume & market
The above code is my universe, when I seem to transform it to a list it does not seem to work. I'm clearly doing something wrong. You can see the rest of my code in the backtest!
Cheers everyone and thanks ahead.