attempt to avoid yahoo finance rate limiting
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Steven Polley 2025-05-07 11:57:33 -06:00
parent 43cd399c18
commit 0110941ac7

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"time"
) )
type security struct { type security struct {
@ -62,6 +63,7 @@ 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) 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 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) balances = append(balances, balance)
ynabAccountIDs = append(ynabAccountIDs, p.data.Accounts[i].YnabAccountID) ynabAccountIDs = append(ynabAccountIDs, p.data.Accounts[i].YnabAccountID)