Hello,
How do you make a custom factor using the "open" as the input? Can any body show with an example?
Thanks
Hello,
How do you make a custom factor using the "open" as the input? Can any body show with an example?
Thanks
hey, here is are some examples:
from quantopian.pipeline import CustomFactor, Pipeline
import numpy
class StdDev(CustomFactor):
def compute(self, today, asset_ids, out, values):
# Calculates the column-wise standard deviation, ignoring NaNs
out[:] = numpy.nanstd(values, axis=0)
class AverageRange(CustomFactor):
inputs=[USEquityPricing.open, USEquityPricing.close]
def compute(self, today, asset_ids, out, opn, clse):
out[:] = np.nanmean(abs(clse-opn), axis=0)
def make_pipeline():
std_dev = StdDev(
inputs=[USEquityPricing.open],
window_length=5
)
avg_rng= AverageRange(
window_length=5
)
return Pipeline(
columns={
'std_dev': std_dev,
'avg_rng': avg_rng
}
)
result = run_pipeline(make_pipeline(), '2018-10-31', '2019-10-31')
result.head()