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
}