vectorbt icon indicating copy to clipboard operation
vectorbt copied to clipboard

Cannot seem to make my strategy go either 1 asset long or 1 asset short

Open StanMorseld opened this issue 1 year ago • 1 comments

I am trying to set up my strategy in such a way that (based on my indicator) it either goes long 1 asset or short 1 asset (i.e., it reverses its position) based on my indicator, since I am trading futures. Therefore, I do not want to sell short (i.e. add cash), but fully reverse my position.

I have already tried to adapt my Portfolio.from_orders or Portfolio.from_signals settings, however this has not worked. If I am not mistaken, the output below should show a size of 1 for all of the orders, right?

image

Does anyone know how to fix this? Thanks in advance!

StanMorseld avatar Nov 14 '22 16:11 StanMorseld

I guess you have the initial capital set to default ($100) and your size is also to default (infinity - go all in/out), since 0.744 * 134.23 = 100. Do vbt.Portfolio.from_signals(..., size=1, ...) to trade with one share.

polakowo avatar Nov 20 '22 18:11 polakowo