6 Star 19 Fork 29

王布衣 / gotdx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
unit.go 734 Bytes
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2024-01-19 08:39 . 统一计算价格小数点后的精度
package internal
import "gitee.com/quant1x/exchange"
// BaseUnit 交易单位
//
// A股、债券交易和债券买断式回购交易的申报价格最小变动单位为0.01元人民币
// 基金、权证交易为0.001元人民币
// B股交易为0.001美元
// 债券质押式回购交易为0.005元
func defaultBaseUnit(marketId exchange.MarketType, code string) float64 {
_ = marketId
c := code[:2]
switch c {
case "60", "68", "00", "30", "39":
return 100.0
}
c = code[:3]
switch c {
case "510":
return 1000.0
}
return 100.00
}
type unitHandler func(marketId exchange.MarketType, code string) float64
var (
BaseUnit unitHandler = defaultBaseUnit
)
func RegisterBaseUnitFunction(f unitHandler) {
BaseUnit = f
}
Go
1
https://gitee.com/quant1x/gotdx.git
git@gitee.com:quant1x/gotdx.git
quant1x
gotdx
gotdx
v1.22.6

搜索帮助