This commit is contained in:
2026-08-26 02:10:05 +08:00
parent f14423418a
commit 550fdbf016
11 changed files with 140 additions and 177 deletions

View File

@@ -1,6 +1,7 @@
package libs
import (
"math"
"math/rand"
"time"
)
@@ -23,3 +24,15 @@ func TradingTime(t time.Time) bool {
return (second >= 9*3600+30*60 && second <= 11*3600+30*60) ||
(second >= 13*3600 && second <= 15*3600)
}
func CalcBuyVolume(price, buyValue float64) int {
if price <= 0 || buyValue <= 0 {
return 0
}
// 不足一手时仍按最低一手委托。
hands := int(math.Floor(buyValue / (price * 100)))
if hands == 0 {
hands = 1
}
return hands * 100
}

View File

@@ -13,7 +13,7 @@ var (
)
// AllowOpen 每次开仓或补仓前取 60 分钟大盘信号,只有 UP 才放行。
func AllowOpen() bool {
func MarketAllowOpen() bool {
// gen url.
fullUrl := fmt.Sprintf("%s%s?period=%s&t=%s", API_HOST, MarketUrl, Period, randStr(16))
payload, err := GetJSON(fullUrl, HTTPTimeout)