You can not exceed the stack size this way, so the problem is somewhere else. But it's a hint that is seems to depend on the lookbacks value. Check for exceeding the length of a series somewhere.

The crash happens inside the compramosSpread function, so it should be easy to find which line it is, by placing watch or print(TO_FILE,..) statements in the function.