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

Questions about backtesting #722

Open
rubix-07 opened this issue Jun 23, 2024 · 0 comments
Open

Questions about backtesting #722

rubix-07 opened this issue Jun 23, 2024 · 0 comments

Comments

@rubix-07
Copy link

rubix-07 commented Jun 23, 2024

Recently I have started using VectorBT for backtesting. As a rookie, I start with something simple, so I found a moving average croosover strategy. However, when I encountered this code: pf = vbt.Portfolio.from_signals(symbol, entries, exits, init_cash=100, freq='1d', sl_stop=0.05, tp_stop=0.2), I noticed that symbol is actually the close price of a stock, let's say AAPL(daily bar). However, if I want to state that, for example, If today is Monday and a golden cross(Both MA using close price) appeared then I buy at the Open tomorrow which is Tuesday, then I should change symbol to the open price of AAPL instead cause it is impossible to execute trades at Monday Close in this case?

If I decide to build a long_signal array like ['False', 'False', 'True', 'False', 'False] (e.g. rsi < 30 is True at Wednesday Close) and then I buy at the open on Thursday, do I need to shift the long_signal array by one to the right so that I'm telling VectorBT the fact that the buy will be done at the open on Thursday instead of on Wednesday?

I have a custom indicator which returns True today if some conditions are met, let say the price crosses and is bigger than a threshold, then I enter at tomorrow open. How can I make sure that the backtester will only enter the trade(in this case is a long) once instead of multiple times if the price is still bigger than the threshold tomorrow?

Any help will be greatly appreciated.

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