Shuffle accounts array on load
This commit is contained in:
parent
a31167ae9c
commit
e2c128feff
|
@ -383,11 +383,14 @@ async function refreshAccounts(
|
|||
try {
|
||||
console.log('Refreshing accounts...');
|
||||
console.time('getAllMangoAccounts');
|
||||
mangoAccounts.splice(0, mangoAccounts.length, ...(await client.getAllMangoAccounts(
|
||||
mangoGroup,
|
||||
undefined,
|
||||
true,
|
||||
)));
|
||||
|
||||
mangoAccounts.splice(
|
||||
0,
|
||||
mangoAccounts.length,
|
||||
...(await client.getAllMangoAccounts(mangoGroup, undefined, true)),
|
||||
);
|
||||
shuffleArray(mangoAccounts);
|
||||
|
||||
console.timeEnd('getAllMangoAccounts');
|
||||
console.log(`Fetched ${mangoAccounts.length} accounts`);
|
||||
} 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) {
|
||||
if (content && process.env.WEBHOOK_URL) {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue