-
Notifications
You must be signed in to change notification settings - Fork 428
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
Long-term backtest with parameters changing over each day #171
Comments
Why not update the parameters within the loop to handle continuous days seamlessly? You can implement the parameter logic directly in the loop. Alternatively, for backtesting efficiency, you could input precomputed updated parameters with associated timestamps, allowing the loop to update parameters at the appropriate times. This approach is a simpler solution. Integrating Custom Data example helps you. But, if you prefer to backtest separately, please refer to the explanation below. Unfortunately, there is currently no built-in way to maintain the trading state across different hftbacktest instances. Regarding equity, you need to write a custom equity aggregator, such as: equity_day_n+1 += equity_day_n[-1]. But, holding the position across days presents a more complex challenge. If your strategy is high-frequency and has a high turnover rate (frequently altering positions), it might be acceptable to ignore the last position from the previous day and start with a zero position at the beginning of the next day. If, but, your PnL is significantly affected by positions held across days and the strategy remains high-frequency, closing positions at the end of the day might be necessary for only backtesting purposes to remove the discrepancy. But, this action could unnecessarily impact your strategy, as it introduces an action that would not need in live trading. Additionally, there is the issue of active orders not being carried over to the next day. This problem is more subtle but can result in losing the queue position during day transitions, which could impact the effectiveness of the strategy. |
Thx a lot, I make it a hbt object that continously running while looping through the parameter dict with timestamp as Key Value. It works out pretty good. |
Hi guy, interesting question and discussion. Tks all.
The use of the constante value for roi for a long-term simulation is a little trick. For exemplo, the BTC-BRL that is super volatile and in one month has gone from 200k to 600k is a huge range. How I can deal with this range?
|
Setting a sufficiently large range consumes more memory but is the simplest approach to handling range variations. For example, if the tick size for BTC-BRL is 1 and the range is 50k to 1000k, the memory consumption would be approximately |
Hi I am currenting trying to make a long-term backtesting by rolling optimized best parameters in last trading day and feed that best parameter set into next trading day.
I tried to do this with a FOR LOOP, I feed the same recorder object over days to function and finally get its stats. But because I need to feed different parameters for each day, I have to init and close a new hbt and asset object for each day. It turns out that the curve will be init to zero for each day as well - which is not my ideal longterm backtest type, I want it to be a continuous trading.
I found Discontinuities by observing the plot of 09-02 to 09-03, which seems that the return and stocking of 09-02 is erased when it comes to 09-03.
Could you please help me to know how to maintain a continous longterm backtesting while keep changing my parameters everyday? Suppose my input data is also a list of well-formated npz files for each day.
Thanks a lot!
The text was updated successfully, but these errors were encountered: