mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86404db551 | ||
|
|
3f3438fca8 | ||
|
|
1656b41f02 | ||
|
|
8090cc7216 | ||
|
|
a3169c67da |
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
func main() {
|
||||
common.Test(func(c *tdx.Client) {
|
||||
resp, err := c.GetKlineDay("000001", 0, 10)
|
||||
resp, err := c.GetKlineDay("838971", 0, 20)
|
||||
logs.PanicErr(err)
|
||||
|
||||
for _, v := range resp.List {
|
||||
|
||||
2
go.mod
2
go.mod
@@ -5,7 +5,7 @@ go 1.20
|
||||
require (
|
||||
github.com/glebarez/go-sqlite v1.22.0
|
||||
github.com/go-sql-driver/mysql v1.7.0
|
||||
github.com/injoyai/base v1.2.15
|
||||
github.com/injoyai/base v1.2.17
|
||||
github.com/injoyai/conv v1.2.5
|
||||
github.com/injoyai/ios v1.2.2
|
||||
github.com/injoyai/logs v1.0.12
|
||||
|
||||
2
go.sum
2
go.sum
@@ -28,6 +28,8 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/injoyai/base v1.2.15 h1:K/ysPqZl7vgNUAz/jpG1IdDpzdSMWvUfoJL+1gPdM9g=
|
||||
github.com/injoyai/base v1.2.15/go.mod h1:NfCQjml3z2pCvQ3J3YcOXtecqXD0xVPKjo4YTsMLhr8=
|
||||
github.com/injoyai/base v1.2.17 h1:+qYeCSeEMWgmTla+LBC0Ozan9ysS4mV0ne5nfMt9opU=
|
||||
github.com/injoyai/base v1.2.17/go.mod h1:NfCQjml3z2pCvQ3J3YcOXtecqXD0xVPKjo4YTsMLhr8=
|
||||
github.com/injoyai/conv v1.2.5 h1:G4OCyF0NTZul5W1u9IgXDOhW4/zmIigdPKXFHQGmv1M=
|
||||
github.com/injoyai/conv v1.2.5/go.mod h1:s05l3fQJQ4mT4VX+KIdbvCWQB0YzZHprmUfUu2uxd1k=
|
||||
github.com/injoyai/ios v1.2.2 h1:fAPWBL6t22DiE2ZEpBgf5bzyVQTcm2ZhLMkM+JFPhZA=
|
||||
|
||||
@@ -20,8 +20,8 @@ func (this Exchange) String() string {
|
||||
return "sz"
|
||||
case ExchangeSH:
|
||||
return "sh"
|
||||
//case ExchangeBJ:
|
||||
//return "bj"
|
||||
case ExchangeBJ:
|
||||
return "bj"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
@@ -33,8 +33,8 @@ func (this Exchange) Name() string {
|
||||
return "上海"
|
||||
case ExchangeSZ:
|
||||
return "深圳"
|
||||
//case ExchangeBJ:
|
||||
//return "北京"
|
||||
case ExchangeBJ:
|
||||
return "北京"
|
||||
default:
|
||||
return "未知"
|
||||
}
|
||||
@@ -43,7 +43,7 @@ func (this Exchange) Name() string {
|
||||
const (
|
||||
ExchangeSZ Exchange = iota //深圳交易所
|
||||
ExchangeSH //上海交易所
|
||||
//ExchangeBJ //北京交易所
|
||||
ExchangeBJ //北京交易所
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -58,6 +58,8 @@ func DecodeCode(code string) (Exchange, string, error) {
|
||||
return ExchangeSH, code[2:], nil
|
||||
case ExchangeSZ.String():
|
||||
return ExchangeSZ, code[2:], nil
|
||||
case ExchangeBJ.String():
|
||||
return ExchangeBJ, code[2:], nil
|
||||
default:
|
||||
return 0, "", fmt.Errorf("股票代码错误,例如:SZ000001")
|
||||
}
|
||||
@@ -237,20 +239,34 @@ func getVolume2(val uint32) float64 {
|
||||
|
||||
// IsStock 是否是股票,示例sz000001
|
||||
func IsStock(code string) bool {
|
||||
if len(code) != 8 {
|
||||
return false
|
||||
}
|
||||
code = strings.ToLower(code)
|
||||
switch {
|
||||
case code[0:2] == ExchangeSH.String() &&
|
||||
(code[2:3] == "6"):
|
||||
return true
|
||||
return IsSZStock(code) || IsSHStock(code) || IsBJStock(code)
|
||||
|
||||
case code[0:2] == ExchangeSZ.String() &&
|
||||
(code[2:3] == "0" || code[2:4] == "30"):
|
||||
return true
|
||||
//if len(code) != 8 {
|
||||
// return false
|
||||
//}
|
||||
//code = strings.ToLower(code)
|
||||
//switch {
|
||||
//case code[0:2] == ExchangeSH.String() &&
|
||||
// (code[2:3] == "6"):
|
||||
// return true
|
||||
//
|
||||
//case code[0:2] == ExchangeSZ.String() &&
|
||||
// (code[2:3] == "0" || code[2:4] == "30"):
|
||||
// return true
|
||||
//}
|
||||
//return false
|
||||
}
|
||||
return false
|
||||
|
||||
func IsSZStock(code string) bool {
|
||||
return len(code) == 8 && strings.ToLower(code[0:2]) == ExchangeSZ.String() && code[2:3] == "0"
|
||||
}
|
||||
|
||||
func IsSHStock(code string) bool {
|
||||
return len(code) == 8 && strings.ToLower(code[0:2]) == ExchangeSH.String() && code[2:3] == "6"
|
||||
}
|
||||
|
||||
func IsBJStock(code string) bool {
|
||||
return len(code) == 8 && strings.ToLower(code[0:2]) == ExchangeBJ.String() && (code[2:4] == "92" || code[2:3] == "8")
|
||||
}
|
||||
|
||||
// IsETF 是否是基金,示例sz159558
|
||||
@@ -290,6 +306,9 @@ func AddPrefix(code string) string {
|
||||
case code[:3] == "159":
|
||||
//深圳基金
|
||||
code = ExchangeSZ.String() + code
|
||||
case code[:1] == "8" || code[:2] == "92":
|
||||
//北京股票
|
||||
code = ExchangeBJ.String() + code
|
||||
}
|
||||
}
|
||||
return code
|
||||
|
||||
Reference in New Issue
Block a user