吧代码的传参方式从sz,000001改成sz000001

This commit is contained in:
钱纯净
2024-11-05 00:18:20 +08:00
parent 39057e5305
commit c90adef204
15 changed files with 84 additions and 139 deletions

View File

@@ -9,6 +9,7 @@ import (
"golang.org/x/text/transform"
"io"
"math"
"strings"
"time"
)
@@ -48,6 +49,20 @@ func UTF8ToGBK(text []byte) []byte {
return bytes.ReplaceAll(content, []byte{0x00}, []byte{})
}
func DecodeCode(code string) (Exchange, string, error) {
if len(code) != 8 {
return 0, "", fmt.Errorf("股票代码长度错误,例如:SZ000001")
}
switch strings.ToLower(code[:2]) {
case ExchangeSH.String():
return ExchangeSH, code[2:], nil
case ExchangeSZ.String():
return ExchangeSZ, code[2:], nil
default:
return 0, "", fmt.Errorf("股票代码错误,例如:SZ000001")
}
}
func FloatUnit(f float64) (float64, string) {
m := []string{"万", "亿"}
unit := ""