You CAN vectorize a back test, to a certain extent. Generate your signals in serial, and then vectorize the fill modeling and do path path length dependency correction.
I do it all the time, and it saves me a ton of time. And no, I don't care to elaborate further..
Then what's the thread or the entire site good for? It's not like anyone is asking you for your "trade secrets". It's impossible to image what you might mean with
*generate signal in serial
* vectorize the fill modeling
* path path length dependency correction
But it surely sounds cute. A simple example would make it crystal clear.
I am by the way not asking for myself, I run backrests in a pure even driven architecture with tens of millions of tick based data points per symbol and it performs perfectly fine. I am not interested in a vectorize approach because it is technically impossible to do so because I use a portfolio backtest approach where even multiple strategies are dependent on each other.
I'm not going to recreate what's already in open source literature (for free) because you lack the imagination to think about ways of doing things differently than your current methods. See one of the first few chapters of the Marcos de Prado Lopez book for some inspiration on the subject.
If you'd like, I can provide a minimal example with full commented source code. Just Google-Pay me $1489.95 first
Translation: you are talking out of your ass and are just too damn proud to admit. Thanks for the confirmation. Just sad there are so many posers and liars on this site.
from multiprocessing import cpu_count, Pool
import pandas as pd
import numpy as np
def _func(func,name,group):
return func(group), name
def df_parallel_apply(grouped,func):
chunksize=cpu_count()
with Pool( chunksize) as p:
args = [(func,name,group) for name, group in grouped]
# list of tuple(result,index)
results = []
while len(args):
args,args2 = args[chunksize:],args[:chunksize]
results2 = p.starmap(_func,args2)
results += results2
ret_list,index = zip(*results)
if len(ret_list):
if type(ret_list[0]) not in [pd.DataFrame,pd.Series]:
df = pd.DataFrame(ret_list,index=index)
df.index.names = grouped.keys
else:
df = pd.concat(ret_list,keys=index)
df.index.names = grouped.keys + (ret_list[0].index.names)
return df
else:
return pd.DataFrame()
Check out this thread, it's absolutely hilarious
https://www.elitetrader.com/et/threads/spy-going-to-260.332384/
Shocking how someone with such flawed knowledge and skillset can bullshit everyone in this thread throughout 5 pages and everyone just goes along with it. Tells you everything about the average intellect of the ET crowd, and this is the technical forum section. Shudder.