def interpfx(time,fx,time_pre):
    opens = np.zeros(len(time))
    f = sp.interpolate.interp1d(time_pre, fx)
    
    for t in range(len(time)):
        try:
            opens[t] = f(time[t])
        except __HOLE__:
            if time[t] < min(time_pre):
                opens[t] = f(min(time_pre))
            elif time[t] > max(time_pre):
                opens[t] = f(max(time_pre))
            else:
                raise ValueError('Interpolation error')
    return opens

# User input
dataset/ETHPy150Open srcole/fxml/scraper/format_fxdata.py/interpfx