Shuffle accounts array on load
This commit is contained in:
parent
a31167ae9c
commit
e2c128feff
|
@ -383,11 +383,14 @@ async function refreshAccounts(
|
||||||
try {
|
try {
|
||||||
console.log('Refreshing accounts...');
|
console.log('Refreshing accounts...');
|
||||||
console.time('getAllMangoAccounts');
|
console.time('getAllMangoAccounts');
|
||||||
mangoAccounts.splice(0, mangoAccounts.length, ...(await client.getAllMangoAccounts(
|
|
||||||
mangoGroup,
|
mangoAccounts.splice(
|
||||||
undefined,
|
0,
|
||||||
true,
|
mangoAccounts.length,
|
||||||
)));
|
...(await client.getAllMangoAccounts(mangoGroup, undefined, true)),
|
||||||
|
);
|
||||||
|
shuffleArray(mangoAccounts);
|
||||||
|
|
||||||
console.timeEnd('getAllMangoAccounts');
|
console.timeEnd('getAllMangoAccounts');
|
||||||
console.log(`Fetched ${mangoAccounts.length} accounts`);
|
console.log(`Fetched ${mangoAccounts.length} accounts`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -1166,6 +1169,13 @@ async function closePositions(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shuffleArray(array) {
|
||||||
|
for (let i = array.length - 1; i > 0; i--) {
|
||||||
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
[array[i], array[j]] = [array[j], array[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function notify(content: string) {
|
function notify(content: string) {
|
||||||
if (content && process.env.WEBHOOK_URL) {
|
if (content && process.env.WEBHOOK_URL) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue