refactor: enhance Optuna backtesting framework, optimize orderbook filtering, and update database management utilities.
This commit is contained in:
35
scratch/find_unclosed_2.py
Normal file
35
scratch/find_unclosed_2.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from html.parser import HTMLParser
|
||||
|
||||
class DivTracker(HTMLParser):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.stack = []
|
||||
self.found = False
|
||||
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if tag == 'div':
|
||||
attrs_dict = dict(attrs)
|
||||
if attrs_dict.get('id') == 'tab-backtest':
|
||||
self.found = True
|
||||
|
||||
if self.found:
|
||||
# store class and id for debugging
|
||||
cls = attrs_dict.get('class', '')
|
||||
id_ = attrs_dict.get('id', '')
|
||||
self.stack.append((self.getpos(), cls, id_))
|
||||
|
||||
def handle_endtag(self, tag):
|
||||
if tag == 'div' and self.found:
|
||||
if self.stack:
|
||||
self.stack.pop()
|
||||
if len(self.stack) == 0:
|
||||
self.found = False # End of tab-backtest
|
||||
|
||||
with open('templates/backtest.html', 'r', encoding='utf-8') as f:
|
||||
html = f.read()
|
||||
|
||||
tracker = DivTracker()
|
||||
tracker.feed(html)
|
||||
print("Unclosed divs inside tab-backtest:")
|
||||
for item in tracker.stack:
|
||||
print(item)
|
||||
Reference in New Issue
Block a user