2 Star 3 Fork 10

王布衣 / engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
market.go 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2024-02-12 22:53 . 适配新版本的pandas
package market
import (
"fmt"
"gitee.com/quant1x/exchange"
"gitee.com/quant1x/gotdx/securities"
"gitee.com/quant1x/num"
)
func GetStockCodeList() []string {
var allCodes []string
// 上海
// sh600000-sh609999
{
var (
codeBegin = 600000
codeEnd = 609999
)
for i := codeBegin; i <= codeEnd; i++ {
fc := fmt.Sprintf("sh%d", i)
if IsNeedIgnore(fc) {
continue
}
allCodes = append(allCodes, fc)
}
}
// 科创板
// sh688000-sh688999
{
var (
codeBegin = 688000
codeEnd = 689999
)
for i := codeBegin; i <= codeEnd; i++ {
fc := fmt.Sprintf("sh%d", i)
if IsNeedIgnore(fc) {
continue
}
allCodes = append(allCodes, fc)
}
}
// 深圳证券交易所
// 深圳主板: sz000000-sz000999
{
var (
codeBegin = 0
codeEnd = 999
)
for i := codeBegin; i <= codeEnd; i++ {
fc := fmt.Sprintf("sz000%03d", i)
if IsNeedIgnore(fc) {
continue
}
allCodes = append(allCodes, fc)
}
}
// 中小板: sz001000-sz009999
{
var (
codeBegin = 1000
codeEnd = 9999
)
for i := codeBegin; i <= codeEnd; i++ {
fc := fmt.Sprintf("sz00%04d", i)
if IsNeedIgnore(fc) {
continue
}
allCodes = append(allCodes, fc)
}
}
// 创业板: sz300000-sz300999
{
var (
codeBegin = 300000
codeEnd = 309999
)
for i := codeBegin; i <= codeEnd; i++ {
fc := fmt.Sprintf("sz%06d", i)
if IsNeedIgnore(fc) {
continue
}
allCodes = append(allCodes, fc)
}
}
//allCodes = allCodes[0:0]
// 港股: hk00001-hk09999
//{
// var (
// codeBegin = 1
// codeEnd = 9999
// )
// for i := codeBegin; i <= codeEnd; i++ {
// fc := fmt.Sprintf("hk%05d", i)
// allCodes = append(allCodes, fc)
// }
//}
return allCodes
}
// GetCodeList 加载全部股票代码
func GetCodeList() []string {
allCodes := make([]string, 0)
// 添加指数代码
allCodes = append(allCodes, exchange.IndexList()...)
// 板块信息
blocks := securities.BlockList()
for _, v := range blocks {
allCodes = append(allCodes, v.Code)
}
stockCodes := GetStockCodeList()
allCodes = append(allCodes, stockCodes...)
return allCodes
}
// PriceLimit 计算涨停板和跌停板的价格
func PriceLimit(securityCode string, lastClose float64) (limitUp, limitDown float64) {
limitRate := exchange.MarketLimit(securityCode)
priceLimitUp := num.Decimal(lastClose * (1.000 + limitRate))
priceLimitDown := num.Decimal(lastClose * (1.000 - limitRate))
return priceLimitUp, priceLimitDown
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v1.8.4

搜索帮助