mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
吧代码的传参方式从sz,000001改成sz000001
This commit is contained in:
@@ -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 := ""
|
||||
|
||||
Reference in New Issue
Block a user