Hello,
I have been trying to use the talib bbands library with in a custom facteur class.
It may come from the fact I am not sure what output is exected from a pipeline.
I have the error:
AssertionError: real has wrong dimensions
Could you please help me understan why?
I am trying to set a trading rule that takes into account the bollinger band width on the VIX to trade XIV.
import pandas as pd
import numpy as np
import talib as ta
from quantopian.pipeline import Pipeline
from quantopian.pipeline.data.builtin import USEquityPricing
from quantopian.pipeline.factors import CustomFactor, Latest
from quantopian.pipeline.data.quandl import cboe_vix, cboe_vxv, cboe_vxd, cboe_vvix
from quantopian.research import run_pipeline
class GetVIX(CustomFactor):
window_length = 1
def compute(self, today, assets, out, vix):
out[:] = vix[-1]
class GetVIXbolls(CustomFactor):
window_length = 20
def compute(self, today, assets, out, vix):
upper, middle, lower = ta.BBANDS(vix, timeperiod = self.window_length, nbdevup = 2, nbdevdn = 2, matype=0)
out[:] = upper - lower
def make_pipeline():
pipe = Pipeline()
pipe.add(GetVIX(inputs = [cboe_vix.vix_close]), 'Vixclose')
pipe.add(GetVIXbolls(inputs = [cboe_vix.vix_close]), 'vixmean')
return pipe
def initialize(context):
pipe = make_pipeline()
result = run_pipeline(make_pipeline(), '2015-03-05', '2015-05-05')
result.head()
Many thanks