2 Star 7 Fork 10

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dateset_trans_count.go 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-12-20 07:47 . 统一数据到factors目录
package factors
import (
"gitee.com/quant1x/engine/cache"
"gitee.com/quant1x/engine/datasource/base"
"gitee.com/quant1x/gotdx/proto"
"gitee.com/quant1x/gotdx/quotes"
)
//var (
// mapFreeCapital = concurrent.NewTreeMap[string, float64]
//)
// CountInflow 统计指定日期的内外盘
func CountInflow(list []quotes.TickTransaction, securityCode string, date string) (summary cache.TurnoverDataSummary) {
if len(list) == 0 {
return
}
securityCode = proto.CorrectSecurityCode(securityCode)
for _, v := range list {
tm := v.Time
direction := int32(v.BuyOrSell)
price := v.Price
vol := int64(v.Vol)
// 统计内外盘数据
if direction == quotes.TDX_TICK_BUY {
// 买入
summary.OuterVolume += vol
summary.OuterAmount += float64(vol) * price
} else if direction == quotes.TDX_TICK_SELL {
// 卖出
summary.InnerVolume += vol
summary.InnerAmount += float64(vol) * price
} else {
// 可能存在中性盘2, 最近又发现有类型是3, 暂时还是按照中性盘来处理
vn := vol
buyOffset := vn / 2
sellOffset := vn - buyOffset
// 买入
summary.OuterVolume += buyOffset
summary.OuterAmount += float64(buyOffset) * price
// 卖出
summary.InnerVolume += sellOffset
summary.InnerAmount += float64(sellOffset) * price
}
// 计算开盘竞价数据
if tm >= base.TradingFirstTime && tm < base.TradingStartTime {
summary.OpenVolume += vol
}
// 计算收盘竞价数据
if tm > base.TradingFinalBiddingTime && tm <= base.TradingLastTime {
summary.CloseVolume += vol
}
}
f10 := GetL5F10(securityCode, date)
if f10 != nil {
summary.OpenTurnZ = f10.TurnZ(summary.OpenVolume)
summary.CloseTurnZ = f10.TurnZ(summary.CloseVolume)
}
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v1.0.5

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385