Hello all,
First error (seen below) has been resolved. See the update via my replies below.
I am relatively new to coding, and even newer to Quantopian. I am trying to conduct some research on alpha factors using alphalens, but am unable to even get the notebook working.
I've also tried re-writing the code to create the pipeline in initialization but the same error occurred. Any help would be greatly appreciated!
I know you all can view in the attached notebook, but I'll copy+paste below for good measure. Here's the code:
# Normal imports
from quantopian.pipeline import Pipeline
from quantopian.research import run_pipeline
from quantopian.pipeline.filters.morningstar import Q1500US
from quantopian.pipeline import CustomFactor
from quantopian.pipeline.data.builtin import USEquityPricing
import pandas as pd
import numpy as np
# Testing factor imports
from quantopian.pipeline.data.morningstar import operation_ratios
from quantopian.pipeline.data.morningstar import valuation_ratios
from quantopian.pipeline.data.morningstar import asset_classification
from quantopian.pipeline.data.morningstar import valuation
from quantopian.pipeline.data.morningstar import earnings_ratios
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Single factor
def custom_factor(CustomFactor):
inputs = [morningstar.valuation_ratios.ps_ratio]
window_length = 1
def compute(self, today, assets, out, ps):
table = pd.DataFrame(index=assets)
table ["ps"] = ps[-1]
out[:] = table.fillna(table.max()).mean(axis=1)
# Factor requiring industry comparison
#def custom_factor(CustomFactor):
# Factor requiring multiple factors
#def custom_factor(CustomFactor):
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def make_pipeline():
testing_factor = custom_factor()
universe = (Q1500US() & testing_factor.notnull())
testing_factor = testing_factor.rank(ascending=true, mask=universe, method='average')
pipe = Pipeline(columns={'testing_factor':testing_factor}, screen = universe)
return pipe
result = run_pipeline(make_pipeline(), start_date='2014-01-01', end_date='2018-01-01')
result.head()
And here's the error:
TypeErrorTraceback (most recent call last)
<ipython-input-18-fce5c027f49a> in <module>()
43 return pipe
44
---> 45 result = run_pipeline(make_pipeline(), start_date='2014-01-01', end_date='2018-01-01')
46 result.head()
<ipython-input-18-fce5c027f49a> in make_pipeline()
37 def make_pipeline():
38
---> 39 testing_factor = custom_factor()
40 universe = (Q1500US() & testing_factor.notnull())
41 testing_factor = testing_factor.rank(ascending=true, mask=universe, method='average')
TypeError: custom_factor() takes exactly 1 argument (0 given)