Embed a pinned FinanceDatabase equity snapshot, add authenticated company search and identity-based follows, preserve legacy assets, and map selected Yahoo symbols for collection. Refs #19 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
841 B
Go
33 lines
841 B
Go
package generation
|
|
|
|
import (
|
|
"github.com/tradarr/backend/internal/models"
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
var yahooTicker = regexp.MustCompile(`^[A-Za-z0-9^][A-Za-z0-9.^=\-]{0,31}$`)
|
|
var figiIdentity = regexp.MustCompile(`^BBG[A-Z0-9]{9}$`)
|
|
|
|
// Only the Yahoo source gets the catalogue's Yahoo listing hint. Other feeds
|
|
// retain the exact historical Symbol input. No guesses or Bloomberg conversion.
|
|
func yahooSymbols(assets []models.UserAsset) []string {
|
|
out := []string{}
|
|
seen := map[string]bool{}
|
|
for _, a := range assets {
|
|
symbol := a.Symbol
|
|
if a.CompanyID != nil {
|
|
if a.YahooSymbol == nil {
|
|
continue
|
|
}
|
|
symbol = *a.YahooSymbol
|
|
}
|
|
if !yahooTicker.MatchString(symbol) || figiIdentity.MatchString(strings.ToUpper(symbol)) || seen[symbol] {
|
|
continue
|
|
}
|
|
seen[symbol] = true
|
|
out = append(out, symbol)
|
|
}
|
|
return out
|
|
}
|