Ajout analyse de rapports
This commit is contained in:
@@ -9,3 +9,12 @@ docker build -t flask-web-app .
|
||||
docker run -it -p 5000:5000 -v $(pwd)/src/:/src -v /home/jerome/Perso/freqtradeDocker/user_data/:/mnt/external flask-web-app bash
|
||||
|
||||
puis : python3 app.py
|
||||
|
||||
## librairies
|
||||
|
||||
### Génération d'un rapport sur le dataframe
|
||||
ydata-profiling : https://github.com/ydataai/ydata-profiling
|
||||
|
||||
profile = ProfileReport(dataframe, tsmode=True, sortby="date", title="Time-Series EDA")
|
||||
|
||||
profile.to_file("report_timeseries.html")
|
||||
@@ -9,3 +9,4 @@ Werkzeug==2.2.3
|
||||
joblib==1.4.2
|
||||
pyarrow
|
||||
pandas-ta
|
||||
ydata-profiling
|
||||
22
src/app.py
22
src/app.py
@@ -6,7 +6,7 @@ import os
|
||||
import pickle
|
||||
import joblib
|
||||
from io import TextIOWrapper
|
||||
|
||||
from ydata_profiling import ProfileReport
|
||||
|
||||
app = Flask(__name__)
|
||||
FREQTRADE_USERDATA_DIR = '/mnt/external'
|
||||
@@ -126,6 +126,26 @@ def read_feather(filename):
|
||||
print(e)
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.route('/generate_report')
|
||||
def generate_report():
|
||||
filename = request.args.get('filename', '')
|
||||
path = os.path.join(FREQTRADE_USERDATA_DIR + "/data/binance/", filename)
|
||||
print(path)
|
||||
indicators = request.args.get('indicators', '').split(',')
|
||||
print(indicators)
|
||||
|
||||
try:
|
||||
dataframe = pd.read_feather(path)
|
||||
print(dataframe.columns)
|
||||
df = dataframe[indicators]
|
||||
profile = ProfileReport(df.loc[1:100], tsmode=True, sortby="date", title="Time-Series EDA")
|
||||
|
||||
profile.to_file(FREQTRADE_USERDATA_DIR + "/reports/report_timeseries.html")
|
||||
return dataframe.to_json(orient="records")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.route('/get_chart_data')
|
||||
def get_chart_data():
|
||||
filename = request.args.get('filename', '')
|
||||
|
||||
@@ -497,10 +497,36 @@ function loadFeather(filename) {
|
||||
element.value = filename
|
||||
fetch(`/read_feather/${filename}`)
|
||||
.then(response => response.json())
|
||||
.then(data => renderChart(data, filename, true) );
|
||||
.then(data => {
|
||||
renderChart(data, filename, true)
|
||||
initReport(data)
|
||||
})
|
||||
}
|
||||
|
||||
function initReport(data) {
|
||||
string = "<ul class='indicators'>" +
|
||||
Object.keys(data[0])
|
||||
// .filter(key => !['date', 'open', 'close', 'volume', 'high', 'low'].includes(key))
|
||||
.map(cols => `<li><label><input id="${cols}" type="checkbox" value="${cols}" onchange="toggleReportIndicator(this)">${cols}</label></li>`)
|
||||
.join('') +
|
||||
"</ul>"
|
||||
|
||||
const indicators = document.getElementById('indicatorsReport')
|
||||
indicators.innerHTML = string
|
||||
}
|
||||
|
||||
function generateReport() {
|
||||
|
||||
const element = document.getElementById('current_file_name');
|
||||
let filename = element.value
|
||||
const indicators = Array.from(selectedReportIndicators).join(',');
|
||||
|
||||
fetch(`/generate_report?filename=${filename}&indicators=${indicators}`)
|
||||
.then(alert('Generation en cours'));
|
||||
}
|
||||
|
||||
let selectedIndicators = new Set();
|
||||
let selectedReportIndicators = new Set();
|
||||
|
||||
function toggleIndicator(checkbox) {
|
||||
const indicator = checkbox.value;
|
||||
@@ -511,6 +537,15 @@ function toggleIndicator(checkbox) {
|
||||
}
|
||||
loadChartWithIndicators();
|
||||
}
|
||||
function toggleReportIndicator(checkbox) {
|
||||
const indicator = checkbox.value;
|
||||
if (checkbox.checked) {
|
||||
selectedReportIndicators.add(indicator);
|
||||
} else {
|
||||
selectedReportIndicators.delete(indicator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function loadChartWithIndicators() {
|
||||
const element = document.getElementById('current_file_name');
|
||||
@@ -542,4 +577,13 @@ function init() {
|
||||
document.getElementById('closeIndicatorsBtn').addEventListener('click', () => {
|
||||
dialog.close();
|
||||
});
|
||||
|
||||
const dialogReport = document.getElementById('indicatorReportDialog');
|
||||
document.getElementById('openIndicatorsReportBtn').addEventListener('click', () => {
|
||||
dialogReport.showModal();
|
||||
});
|
||||
|
||||
document.getElementById('closeIndicatorsReportBtn').addEventListener('click', () => {
|
||||
dialogReport.close();
|
||||
});
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<button id="openIndicatorsBtn" style="height: 40px;">Afficher les indicateurs</button>
|
||||
<button id="openIndicatorsBtn" style="height: 40px;">Grahique / Indicateurs</button>
|
||||
|
||||
<dialog id="indicatorDialog">
|
||||
<h3>Indicateurs</h3>
|
||||
@@ -40,6 +40,18 @@
|
||||
<button id="closeIndicatorsBtn">Fermer</button>
|
||||
</dialog>
|
||||
|
||||
<button id="openIndicatorsReportBtn" style="height: 40px;">Rapport / Indicateurs</button>
|
||||
|
||||
<dialog id="indicatorReportDialog">
|
||||
<h3>Rapport</h3>
|
||||
<div id="indicatorsReport">
|
||||
<!-- Contenu dynamique ici -->
|
||||
</div>
|
||||
<button id="closeIndicatorsReportBtn">Fermer</button>
|
||||
<button id="generateReport" style="height: 40px;" onclick="generateReport(this.value)">Rapport</button>
|
||||
|
||||
</dialog>
|
||||
|
||||
</div>
|
||||
<div id='content' class="content">
|
||||
<div id="json-tabs">
|
||||
|
||||
Reference in New Issue
Block a user