This commit is contained in:
Dung Nguyen 2022-03-08 22:27:44 +07:00
parent 44b67d9278
commit cc5b0daee9
2 changed files with 36 additions and 6 deletions

32
analytics.js Normal file
View File

@ -0,0 +1,32 @@
const db = require("./database");
db.query(
`select * from analytics WHERE count >= 3`,
[],
(error, results) => {
if (error) {
console.log(error);
} else {
const obj = {};
results.forEach((e, i) => {
if (typeof obj[e.count] === 'undefined') {
obj[e.count] = {
prev: {},
next: {},
}
}
if (results[i - 1]) {
obj[e.count].prev[results[i - 1].count] = (obj[e.count].prev[results[i - 1].count] || 0) + 1;
}
if (results[i + 1]) {
obj[e.count].next[results[i + 1].count] = (obj[e.count].next[results[i + 1].count] || 0) + 1;
}
});
console.log(obj);
}
}
);

View File

@ -48,7 +48,7 @@ let isShowWarningInterrupted = false;
const CONFIG = { const CONFIG = {
autoTrade: true, autoTrade: true,
countTradeContinue: 3, // 7 lệnh thông thì đánh ngược lại countTradeContinue: 3, // 7 lệnh thông thì đánh ngược lại
moneyEnterOrder: [5, 5, 10, 20, 30], // Nếu gặp 7 lệnh thông sẽ đánh ngược lại với từng mệnh giá này moneyEnterOrder: [5, 10, 20, 35, 70, 125, 0, 0, 0, 0, 0, 0, 0, 0], // Nếu gặp 7 lệnh thông sẽ đánh ngược lại với từng mệnh giá này
maxHistory: 40, // Lưu lại lịch sử 40 phiên maxHistory: 40, // Lưu lại lịch sử 40 phiên
historys: [], // Lịch sử lệnh historys: [], // Lịch sử lệnh
enterOrderList: [], // Lệnh đang vào enterOrderList: [], // Lệnh đang vào
@ -74,7 +74,7 @@ puppeteer
await Promise.all([page.waitForNavigation()]); await Promise.all([page.waitForNavigation()]);
const job = new cron.CronJob({ const job = new cron.CronJob({
cronTime: "45 0/1 * * * *", cronTime: "50 0/1 * * * *",
onTick: async function () { onTick: async function () {
await page.reload({ waitUntil: ["networkidle0"] }); await page.reload({ waitUntil: ["networkidle0"] });
}, },
@ -84,8 +84,8 @@ puppeteer
await cdp.send("Network.enable"); await cdp.send("Network.enable");
await cdp.send("Page.enable"); await cdp.send("Page.enable");
let id = 1; let id = 1;
let count = 0;
let countStaticData = 0; let countStaticData = 0;
let count;
const printResponse = async function (cdp, response) { const printResponse = async function (cdp, response) {
if (!response.response || !page || !page.evaluate) { if (!response.response || !page || !page.evaluate) {
@ -147,9 +147,8 @@ puppeteer
} else if (finalSide === "NORMAL") { } else if (finalSide === "NORMAL") {
lastResult = 2; lastResult = 2;
} }
// Không tính nến chờ
if (currentSessionID !== -1) { if (currentSessionID !== -1) {
// Không tính nến chờ
roleEnterOrder(dataParse.session, lastResult); roleEnterOrder(dataParse.session, lastResult);
// TeleGlobal.sendMessage( // TeleGlobal.sendMessage(
// TELEGRAM_CHANNEL, // TELEGRAM_CHANNEL,
@ -578,7 +577,6 @@ function roleEnterOrder(sessionID, lastResult) {
CONFIG.moneyEnterOrder[currentEnterOrder.ind] * 0.95 CONFIG.moneyEnterOrder[currentEnterOrder.ind] * 0.95
})` })`
); );
deleteCurrentEnterOrder(); deleteCurrentEnterOrder();
} else { } else {
// Nếu vẫn còn vốn xoay vòng thì đánh tiếp // Nếu vẫn còn vốn xoay vòng thì đánh tiếp