This commit is contained in:
2026-08-24 20:53:21 +08:00
commit 6e78bba16a
287 changed files with 32443 additions and 0 deletions

51
com/utils.go Normal file
View File

@@ -0,0 +1,51 @@
package com
import (
"github.com/banbox/banbot/strat"
"github.com/banbox/banexg/log"
"go.uber.org/zap"
)
func FastOpen(s *strat.StratJob, dirt, slLong, slShort, limit float64) {
openTag := "long"
stopLoss := slLong
if dirt < 0 {
openTag = "short"
stopLoss = slShort
}
if !s.CanOpen(dirt < 0) {
return
}
err := s.OpenOrder(&strat.EnterReq{
Tag: openTag,
Short: dirt < 0,
Limit: limit,
StopLoss: stopLoss,
})
if err != nil {
log.Error("open fail", zap.Error(err))
}
}
func MakePairInfos(warmNum int) func(s *strat.StratJob) []*strat.PairSub {
return func(s *strat.StratJob) []*strat.PairSub {
var bigTF string
switch s.TimeFrame {
case "1d":
bigTF = "1w"
case "4h":
bigTF = "1d"
case "1h":
bigTF = "8h"
case "15m":
bigTF = "2h"
case "5m":
bigTF = "1h"
case "1m":
bigTF = "15m"
}
return []*strat.PairSub{
{Pair: "_cur_", TimeFrame: bigTF, WarmupNum: warmNum},
}
}
}