vectorbt
vectorbt copied to clipboard
How to implement portfolio from signals with 'exit' column?
I have a Pandas DataFrame with time-series index and columns close_price, long_signal, short_signal, exit
.
I am trying to backtest the strategy which can go both long or short but the constraint is that only one position should be active at one time nor there is adding to positions. The 'exit' column should be the exit signal for any active position, either long or short. Also if I am already in a long or short position, then until the exit signal arrives I should ignore all other long or short signals. Each strategy should also use ALL available capital for trading in order to allow for compounding, I assume the parameter for this is size_type='all'
?
I used:
pf = vbt.Portfolio.from_signals(close=df.close_price, entries=df.long_signal, exits=df.exit, short_entries=df.short_signal, short_exits=df.exit, init_cash='auto', freq='1s', fixed_fees=0.000025')
however I get an error ValueError: Attempt to go in short direction infinitely
which indicates I am not doing things correctly. Any advice? Thanks
This issue is stale because it has been open for 90 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.