timelyart / Kairos

Kairos aims to help you save time by automating repetitive tasks on TradingView such as scanning markets for setups, and refreshing alerts as well as creating new ones.
GNU General Public License v3.0
71 stars 31 forks source link

Chart layout not loading after refresh #85

Closed mrcrdwd closed 1 year ago

mrcrdwd commented 1 year ago

Since a few days, I've been running into the issue that after the set REFRESH_INTERVAL, the browser doesn't reload back into the chart layout but instead opens the general "market overview" this one. This breaks the flow that follows. Mainly due to the fact that when back_test_strategy_symbol() is called again it obviously can't find the Performance Overview tab.

I can't really tell if this is an isolated case or that I broke something but it's been consistent in my backtests recently.

And just curious, why do we need the REFRESH_INTERVAL in the first place? My guests would be that it helps if your backtest somehow gets stuck, a refresh might bring it back to life?

timelyart commented 1 year ago

The REFRESH_INTERVAL is used within the refresh_session method. A session refresh was added so that TV doesn't log you out after a session expires. I vividly remember that tests would fail if they took longer than an hour. This may no longer be a thing though.

For things getting stuck the refresh method is used which is also called by refresh_session. Seems to me the refresh method is breaking things nowadays. Would be a shame to lose the method. It has been rather useful to get around unhandled exceptions that are difficult to reproduce.

I'll look into it.

timelyart commented 1 year ago

Can you share which driver and browser version you are using, please?

timelyart commented 1 year ago

I was able to reproduce the bug. Not quite sure why it broke but I am working on a fix.

mrcrdwd commented 1 year ago

I changed the REFRESH_INTERVAL to 4 hours and a 3-hour backtest was completed successfully.

I can see how the refresh is helpful for getting unstuck so keeping it in place sounds like a good idea. It's weird that suddenly the chart layout isn't opened anymore by default.

Can you share which driver and browser version you are using, please?

The recent tests were done using browser version: 107.0.5304.121 and driver version: 107.0.5304.62 on a headless linux machine. Something that recently changed was that I had to set use_proxy_display to true. That wasn't needed in the older drivers. It could be totally unrelated.

mrcrdwd commented 1 year ago

I was able to reproduce the bug. Not quite sure why it broke but I am working on a fix.

Let me know if I can help.

timelyart commented 1 year ago

Well, I found it. Opening a chart layout creates a new tab. This has been for a while but I guess you and me both haven't been running Kairos for a long enough time for the refresh to trigger. Kairos basically closed the wrong tab.

I expect to commit a fix in a couple of hours after some final testing.

timelyart commented 1 year ago

Fixed in release v2.85.