mirror of
https://github.com/chrisnov-it/quantumbotx.git
synced 2026-07-29 03:37:45 +00:00
Refactor and update bot management and routing
- Update `.gitignore` to include `lab/` for backtesting and raw data. - Refactor `app.py` to improve error handling and logging. - Remove deprecated files: `core/bot_logic.py`, `core/bots/base_bot.py`, `core/bots/manager.py`, `core/db/database.py`, `core/routes/api_analysis.py`, `core/routes/api_bots_analysis.py`, `core/strategies/logic_ma.py`, `core/strategies/logic_rsi.py`. - Modify multiple files to enhance bot management, routing, and strategy handling. - Update JavaScript and HTML templates for better UI and functionality.
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const flatted = require('flatted');
|
||||
|
||||
function tryParse(filePath, defaultValue) {
|
||||
let result;
|
||||
try {
|
||||
result = readJSON(filePath);
|
||||
} catch (ex) {
|
||||
result = defaultValue;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read json file synchronously using flatted
|
||||
*
|
||||
* @param {String} filePath Json filepath
|
||||
* @returns {*} parse result
|
||||
*/
|
||||
function readJSON(filePath) {
|
||||
return flatted.parse(
|
||||
fs.readFileSync(filePath, {
|
||||
encoding: 'utf8',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write json file synchronously using circular-json
|
||||
*
|
||||
* @param {String} filePath Json filepath
|
||||
* @param {*} data Object to serialize
|
||||
*/
|
||||
function writeJSON(filePath, data) {
|
||||
fs.mkdirSync(path.dirname(filePath), {
|
||||
recursive: true,
|
||||
});
|
||||
fs.writeFileSync(filePath, flatted.stringify(data));
|
||||
}
|
||||
|
||||
module.exports = { tryParse, readJSON, writeJSON };
|
||||
Reference in New Issue
Block a user