mirror of
https://github.com/chrisnov-it/quantumbotx.git
synced 2026-07-27 18:57:47 +00:00
78737b6835
- 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.
103 lines
2.8 KiB
JavaScript
103 lines
2.8 KiB
JavaScript
'use strict';
|
|
|
|
const getTokenizer = require('../utils/get-tokenizer.cjs');
|
|
const sourceMap = require('./sourceMap.cjs');
|
|
const tokenBefore = require('./token-before.cjs');
|
|
const types = require('../tokenizer/types.cjs');
|
|
|
|
const REVERSESOLIDUS = 0x005c; // U+005C REVERSE SOLIDUS (\)
|
|
|
|
function processChildren(node, delimeter) {
|
|
if (typeof delimeter === 'function') {
|
|
let prev = null;
|
|
|
|
node.children.forEach(node => {
|
|
if (prev !== null) {
|
|
delimeter.call(this, prev);
|
|
}
|
|
|
|
this.node(node);
|
|
prev = node;
|
|
});
|
|
|
|
return;
|
|
}
|
|
|
|
node.children.forEach(this.node, this);
|
|
}
|
|
|
|
function createGenerator(config) {
|
|
const types$1 = new Map();
|
|
|
|
for (let [name, item] of Object.entries(config.node)) {
|
|
const fn = item.generate || item;
|
|
|
|
if (typeof fn === 'function') {
|
|
types$1.set(name, item.generate || item);
|
|
}
|
|
}
|
|
|
|
return function(node, options) {
|
|
let buffer = '';
|
|
let prevCode = 0;
|
|
let handlers = {
|
|
node(node) {
|
|
if (types$1.has(node.type)) {
|
|
types$1.get(node.type).call(publicApi, node);
|
|
} else {
|
|
throw new Error('Unknown node type: ' + node.type);
|
|
}
|
|
},
|
|
tokenBefore: tokenBefore.safe,
|
|
token(type, value) {
|
|
prevCode = this.tokenBefore(prevCode, type, value);
|
|
|
|
this.emit(value, type, false);
|
|
|
|
if (type === types.Delim && value.charCodeAt(0) === REVERSESOLIDUS) {
|
|
this.emit('\n', types.WhiteSpace, true);
|
|
}
|
|
},
|
|
emit(value) {
|
|
buffer += value;
|
|
},
|
|
result() {
|
|
return buffer;
|
|
}
|
|
};
|
|
|
|
if (options) {
|
|
if (typeof options.decorator === 'function') {
|
|
handlers = options.decorator(handlers);
|
|
}
|
|
|
|
if (options.sourceMap) {
|
|
handlers = sourceMap.generateSourceMap(handlers);
|
|
}
|
|
|
|
if (options.mode in tokenBefore) {
|
|
handlers.tokenBefore = tokenBefore[options.mode];
|
|
}
|
|
}
|
|
|
|
const publicApi = {
|
|
node: (node) => handlers.node(node),
|
|
children: processChildren,
|
|
token: (type, value) => handlers.token(type, value),
|
|
tokenize: function (chunk) {
|
|
const tokenize = getTokenizer.getTokenizer(config);
|
|
|
|
return tokenize(chunk, (type, start, end) => {
|
|
this.token(type, chunk.slice(start, end));
|
|
});
|
|
}
|
|
};
|
|
|
|
handlers.node(node);
|
|
|
|
return handlers.result();
|
|
};
|
|
}
|
|
|
|
exports.createGenerator = createGenerator;
|