Files
big-qmt/go-client/apps/zt/logic/open.go

39 lines
994 B
Go
Raw Normal View History

2026-08-25 18:59:18 +08:00
package logic
2026-08-25 16:40:18 +08:00
import (
2026-08-25 22:35:44 +08:00
"big-qmt/go-client/config"
"big-qmt/go-client/libs"
2026-08-25 16:40:18 +08:00
"big-qmt/go-client/sdk"
)
2026-08-26 02:10:05 +08:00
func openSignal(client *sdk.Client, books *OrderBook, ticks map[string]sdk.Tick, openSignals []libs.SignalItem) {
2026-08-25 22:35:44 +08:00
state := getState()
2026-08-25 16:40:18 +08:00
if state.LoadError != "" {
logf("ERROR", "[ZT][开仓] 状态文件异常,禁止新开仓: %s", state.LoadError)
return
}
2026-08-26 02:10:05 +08:00
for _, item := range openSignals {
if state.Get(item.Code) != nil {
2026-08-25 16:40:18 +08:00
continue
}
2026-08-26 02:10:05 +08:00
price := ticks[item.Code].LastPrice
2026-08-25 16:40:18 +08:00
if price <= 0 {
continue
}
2026-08-26 02:10:05 +08:00
if !dipTriggered(&openDip.mu, openDip.store, "开仓", item.Code, price) {
2026-08-25 16:40:18 +08:00
continue
}
2026-08-26 02:10:05 +08:00
volume := libs.CalcBuyVolume(price, config.Account.BuyValue)
2026-08-25 16:40:18 +08:00
if volume <= 0 {
continue
}
2026-08-25 22:35:44 +08:00
orderID := newOrderTag("base")
2026-08-26 02:10:05 +08:00
if !books.place(ctx, client, sideBuy, item.Code, volume, orderID) {
2026-08-25 16:40:18 +08:00
continue
}
2026-08-26 02:10:05 +08:00
setPending(state.Ensure(item.Code), pendingBaseOpening, orderID)
2026-08-25 16:40:18 +08:00
state.Save()
2026-08-26 02:10:05 +08:00
logf("INFO", "[ZT][开仓] %s 买入 %d 股", item.Code, volume)
2026-08-25 16:40:18 +08:00
}
}