Hi!
I am trying to pass a variable to my pipeline so that I can change the window_length
arguments depending on some other factor. You could change this depending on macroeconomic conditions, volatility, credit spreads, etc...
Below is a simple example where I try to manually change the window length from 10 to 100 but I wasn't able to get this to work. In fact, in my backtest when I put log.info() code into my pipeline function, I could only ever see make_pipeline() being executed once.
make_pipeline() doesn't take any context or data arguments so I am trying to figure out how can I make my window length dynamic and potentially dependent on various market states? Looks like I can't use global variables either.
Apologies if I'm making a dumb newbie Python error. Trying my best here. Thanks!
WIN_LENGTH = 10
def make_pipeline():
mean_close_XX = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=WIN_LENGTH)
log.info('Your window length is %d' % WIN_LENGTH)
return Pipeline(
columns={
'XX_day_mean_close': mean_close_XX
}
)
def before_trading_start(context, data):
global WIN_LENGTH
WIN_LENGTH = 100
po = pipeline_output('my_pipeline')