diff --git a/sync-bitcoin.js b/sync-bitcoin.js index 1ab5a3e..ead09d1 100644 --- a/sync-bitcoin.js +++ b/sync-bitcoin.js @@ -48,14 +48,16 @@ async function getBitcoinPrice() { if (account.closed) { continue; } - const note = await getAccountNote(account); + const cutoffDate = new Date(); + cutoffDate.setDate(cutoffDate.getDate() + 1); + const note = await getAccountNote(account, cutoffDate); if (!note || note.indexOf("BTC:") === -1) { continue; } const btc_amount = note.split('BTC:')[1].split(' ')[0]; const currentBalance = await getAccountBalance(account); const targetBalance = Math.round(bitcoinPrice * btc_amount * 100); - const diff = currentBalance - targetBalance; + const diff = targetBalance - currentBalance; if (diff != 0) { await api.importTransactions(account.id, [{ date: new Date(),