implement rudimentary caching for yahoo finance to avoid http 429 rate limiting
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-05-07 19:59:30 -06:00
parent 13291da691
commit 61074bfd80
3 changed files with 31 additions and 5 deletions

View File

@@ -6,7 +6,6 @@ import (
"fmt"
"io"
"os"
"time"
)
type security struct {
@@ -48,6 +47,8 @@ func (p *Provider) Configure() error {
return fmt.Errorf("failed to create new client: %v", err)
}
chartCache = make(map[string]chartCacheEntry)
return nil
}
@@ -63,7 +64,6 @@ func (p *Provider) GetBalances() ([]int, []string, error) {
return balances, ynabAccountIDs, fmt.Errorf("failed to get quote for security with symbol '%s': %v", p.data.Accounts[i].Securities[j].Symbol, err)
}
balance += price * p.data.Accounts[i].Securities[j].Quantity
time.Sleep(time.Second) // Disgusting way to avoid HTTP 429 rate limiting
}
balances = append(balances, balance)
ynabAccountIDs = append(ynabAccountIDs, p.data.Accounts[i].YnabAccountID)