Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple assets with adjust_sl_func_nb #758

Open
sergejlazuk opened this issue Nov 26, 2024 · 0 comments
Open

Multiple assets with adjust_sl_func_nb #758

sergejlazuk opened this issue Nov 26, 2024 · 0 comments

Comments

@sergejlazuk
Copy link

sergejlazuk commented Nov 26, 2024

Hello,
I would like to pass different arguments per Asset (price columns) into adjust_sl_func_nb. I use adjust_sl_args callback.

For same args for all assets it works, e.g. like this: (here I pass 10 and 20 as inputs into adjust_sl_func_nb which is used by all assets):

pf=vbt.Portfolio.from_signals(
        close=np.array([[10.,20.,30.,40.],[100.,200.,300.,400.]]).T,
        entries=np.array([[True,False,False,False],[True,False,False,False]]).T,
        size=1, size_type='Amount',direction='LongOnly',
        use_stops=True,
	adjust_sl_func_nb=my_adjust_sl_func_nb, 
        adjust_sl_args=(10., 20.), 
        init_cash=10000)

But how do i pass different args per asset?
I tried as below (tuple of tuples), but it does not work:

pf=vbt.Portfolio.from_signals(
        close=np.array([[10.,20.,30.,40.],[100.,200.,300.,400.]]).T,
        entries=np.array([[True,False,False,False],[True,False,False,False]]).T,
        size=1, size_type='Amount',direction='LongOnly',
        use_stops=True,
	adjust_sl_func_nb=my_adjust_sl_func_nb,
        adjust_sl_args=((10., 20.), (11., 21.)),
        init_cash=10000)

Error:

No implementation of function Function(<built-in function sub>) found for signature:
 
 >>> sub(float64, UniTuple(float64 x 2))

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant