You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all
I've tried to use multiprocessing with Portfolio.from_signals() for different chunks of exit signals. Thought this makes sense as the chunks don't depend on one another.
However the results of total_return() are much larger than when I run it in a single process (e.g. 200%+ vs 120%), although if I sort the results their order is the same as in the single process - so it looks like some extra fixed 'addition' is made somewhere.
total_returns, chunk_returns = [], []
with Pool() as p:
for stop in vals:
mask = sl_stops.columns.get_level_values('stop_value') == stop
chunk_stops = sl_stops.loc[:, mask]
args = ohlcv['Open'], entries, chunk_stops
chunk_returns += [p.apply_async(get_total_return, args)]
if len(chunk_returns) == 4 or (stop == vals[-1] and chunk_returns):
total_returns += [r.get() for r in chunk_returns]
chunk_returns = []
def get_total_return(close, short_entries, short_exits):
dema_pf = vbt.Portfolio.from_signals(close=close,
short_entries=short_entries,
short_exits=short_exits,
freq='1d')
tr = dema_pf.total_return()
del dema_pf
gc.collect()
return tr
I know that multiprocessing support isn't declared, just thought it'd be useful and save time for someone else.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all
I've tried to use multiprocessing with Portfolio.from_signals() for different chunks of exit signals. Thought this makes sense as the chunks don't depend on one another.
However the results of total_return() are much larger than when I run it in a single process (e.g. 200%+ vs 120%), although if I sort the results their order is the same as in the single process - so it looks like some extra fixed 'addition' is made somewhere.
I know that multiprocessing support isn't declared, just thought it'd be useful and save time for someone else.
Beta Was this translation helpful? Give feedback.
All reactions