2023-02-21 09:05:16 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
|
|
|
var renameMapping = map[string]string{
|
|
|
|
"STT": "SNT",
|
|
|
|
}
|
|
|
|
|
|
|
|
func RenameSymbols(symbols []string) (renames []string) {
|
|
|
|
for _, symbol := range symbols {
|
|
|
|
renames = append(renames, GetRealSymbol(symbol))
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-04-25 12:15:07 +00:00
|
|
|
func RemoveDuplicates(strings []string) []string {
|
|
|
|
uniqueStrings := make(map[string]bool)
|
|
|
|
var uniqueSlice []string
|
|
|
|
for _, str := range strings {
|
|
|
|
if !uniqueStrings[str] {
|
|
|
|
uniqueStrings[str] = true
|
|
|
|
uniqueSlice = append(uniqueSlice, str)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return uniqueSlice
|
|
|
|
}
|
|
|
|
|
2023-02-21 09:05:16 +00:00
|
|
|
func GetRealSymbol(symbol string) string {
|
|
|
|
if val, ok := renameMapping[strings.ToUpper(symbol)]; ok {
|
|
|
|
return val
|
|
|
|
}
|
|
|
|
return strings.ToUpper(symbol)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ChunkSymbols(symbols []string, chunkSizeOptional ...int) [][]string {
|
|
|
|
var chunks [][]string
|
2023-03-30 12:28:08 +00:00
|
|
|
chunkSize := 100
|
2023-02-21 09:05:16 +00:00
|
|
|
if len(chunkSizeOptional) > 0 {
|
|
|
|
chunkSize = chunkSizeOptional[0]
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < len(symbols); i += chunkSize {
|
|
|
|
end := i + chunkSize
|
|
|
|
|
|
|
|
if end > len(symbols) {
|
|
|
|
end = len(symbols)
|
|
|
|
}
|
|
|
|
|
|
|
|
chunks = append(chunks, symbols[i:end])
|
|
|
|
}
|
|
|
|
|
|
|
|
return chunks
|
|
|
|
}
|