travail avec le contenu des backtests et amélioration graphs avec puces
This commit is contained in:
27
src/app.py
27
src/app.py
@@ -18,10 +18,10 @@ def home():
|
||||
files = os.listdir(FREQTRADE_USERDATA_DIR + "/backtest_results")
|
||||
|
||||
# Filtre pour obtenir uniquement les fichiers (pas les dossiers)
|
||||
files = [f for f in files if os.path.isfile(os.path.join(FREQTRADE_USERDATA_DIR + "/backtest_results", f))]
|
||||
files = [f for f in files if os.path.isfile(os.path.join(FREQTRADE_USERDATA_DIR + "/backtest_results", f)) and f.lower().endswith('.zip')]
|
||||
|
||||
files2 = os.listdir(FREQTRADE_USERDATA_DIR + "/data/binance")
|
||||
files2 = [f for f in files2 if os.path.isfile(os.path.join(FREQTRADE_USERDATA_DIR + "/data/binance", f))]
|
||||
files2 = [f for f in files2 if os.path.isfile(os.path.join(FREQTRADE_USERDATA_DIR + "/data/binance", f)) and f.lower().endswith('.feather')]
|
||||
|
||||
# Retourne le template avec la liste des fichiers
|
||||
return render_template('index.html', files=files, files2=files2)
|
||||
@@ -63,30 +63,41 @@ def read_json(filename):
|
||||
for name in z.namelist():
|
||||
if name.endswith('.json'):
|
||||
with z.open(name) as f:
|
||||
print(f"load_json {name}")
|
||||
zip_contents[name] = json.load(f)
|
||||
elif name.endswith('.feather'):
|
||||
with z.open(name) as f:
|
||||
dataframe = pd.read_feather(f)
|
||||
zip_contents[name] = dataframe.to_json(orient="records")
|
||||
|
||||
elif name.endswith('.pkl'):
|
||||
with z.open(name) as f:
|
||||
try:
|
||||
data = joblib.load(f)
|
||||
if isinstance(data, pd.DataFrame):
|
||||
print("dataframe")
|
||||
zip_contents[name] = data.to_csv() #orient='split'), 200, {'Content-Type': 'application/json'}
|
||||
print(f"dataframe {name}")
|
||||
zip_contents[name] = data.to_json(orient='records') #, 200, {'Content-Type': 'application/json'}
|
||||
elif isinstance(data, dict):
|
||||
# On suppose qu’il y a un seul modèle/clé au premier niveau
|
||||
outer_key = list(data.keys())[0]
|
||||
inner_dict = data[outer_key]
|
||||
|
||||
if isinstance(inner_dict, dict):
|
||||
print(f"dict {name}")
|
||||
# On suppose qu’il y a une seule paire (ex: 'BTC/USDT')
|
||||
inner_key = list(inner_dict.keys())[0]
|
||||
df = inner_dict[inner_key]
|
||||
print(df)
|
||||
if isinstance(df, pd.DataFrame):
|
||||
zip_contents[name] = df.to_html() #json(orient='split'), 200, {'Content-Type': 'application/json'}
|
||||
type = name
|
||||
# if "signals" in name:
|
||||
# type = 'signals'
|
||||
# elif "exited" in name:
|
||||
# type = "exited"
|
||||
zip_contents[type] = df.to_json(orient='records') #, 200, {'Content-Type': 'application/json'}
|
||||
elif isinstance(data, list):
|
||||
print('list')
|
||||
print(f"list {name}")
|
||||
df = pd.DataFrame(data)
|
||||
zip_contents[name] = df.to_html() #orient='split'), 200, {'Content-Type': 'application/json'}
|
||||
zip_contents[name] = df.to_json(orient='records') # , 200, {'Content-Type': 'application/json'}
|
||||
else:
|
||||
zip_contents[name] = json.dumps({"error": f"Type {type(data)} non géré."}), 200
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user