29 lines
798 B
Go
29 lines
798 B
Go
package models
|
|
|
|
const (
|
|
SourceYahooFinance = "yahoo_finance"
|
|
SourceBloomberg = "bloomberg"
|
|
SourceInvesting = "investing_com"
|
|
SourceWatcherGuru = "watcher_guru" // Historical identity; no longer executable.
|
|
SourceCNBCBusiness = "cnbc_business"
|
|
)
|
|
|
|
func SupportedSourceKey(key string) bool {
|
|
switch key {
|
|
case SourceYahooFinance, SourceBloomberg, SourceCNBCBusiness, SourceInvesting:
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
func (s Source) Supported() bool { return s.SourceKey != nil && SupportedSourceKey(*s.SourceKey) }
|
|
func (s Source) Operational() bool { return s.Enabled && s.Supported() }
|
|
func OperationalSources(sources []Source) []Source {
|
|
result := []Source{}
|
|
for _, source := range sources {
|
|
if source.Operational() {
|
|
result = append(result, source)
|
|
}
|
|
}
|
|
return result
|
|
}
|