Back to Community
Fetcher and time shift (improving Q examples?)

I was punishing myself by using fetcher again and I ran into the look ahead bias. Now, look ahead bias is only relevant for backtesting not for live trading as you always want the latest value as we cannot look into the future. So as far as I understand all these sample algorithms will create a lag in the data the moment you will put it live. Should we not assume that any algo we develop will be able to run live and therefor all examples should have a get_environment test something like this when they time shift?

def fixit(df):  
    df  = df.rename(columns={'Value': 'Signal'})  
    if get_environment('arena') == 'backtest':  
        df = df.tshift(3, freq='M')  
    df['symbol'] = 'IPI'  
    df = df[['Signal','symbol', 'sid']]  
    return df