[update] 去掉持久化

This commit is contained in:
lychiyu 2024-07-29 07:50:20 +08:00
parent ae775303f6
commit 855ce2324d
2 changed files with 18 additions and 12 deletions

View File

@ -1,10 +1,10 @@
persistence:
json:
directory: var/data
redis:
host: 127.0.0.1
port: 6379
db: 0
#persistence:
# json:
# directory: var/data
# redis:
# host: 127.0.0.1
# port: 6379
# db: 0
sessions:
binance_futures:

View File

@ -112,6 +112,9 @@ func (s *Strategy) cancelOrders(ctx context.Context, symbol string) {
if err := s.orderExecutors[symbol].GracefulCancel(ctx); err != nil {
log.WithError(err).Errorf("failed to cancel orders")
}
s.Traded[symbol] = false
s.TradeType[symbol] = ""
}
func (s *Strategy) placeOrders(ctx context.Context, kline types.KLine) {
@ -326,10 +329,10 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor qbtrade.OrderExecutor,
s.orderExecutors[symbol] = qbtrade.NewGeneralOrderExecutor(session, symbol, ID, s.InstanceID(), s.Positions[symbol])
s.orderExecutors[symbol].BindEnvironment(s.Environment)
_ = s.orderExecutors[symbol].GracefulCancel(ctx)
s.orderExecutors[symbol].BindProfitStats(s.ProfitStats[symbol])
s.orderExecutors[symbol].TradeCollector().OnPositionUpdate(func(position *types.Position) {
qbtrade.Sync(ctx, s)
})
//s.orderExecutors[symbol].BindProfitStats(s.ProfitStats[symbol])
//s.orderExecutors[symbol].TradeCollector().OnPositionUpdate(func(position *types.Position) {
// qbtrade.Sync(ctx, s)
//})
s.orderExecutors[symbol].Bind()
// 初始化
@ -352,7 +355,10 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor qbtrade.OrderExecutor,
if !s.Traded[symbol] {
// 如若在下一根k线未成交 则取消订单
s.cancelOrders(ctx, symbol)
if s.TradeType[symbol] != "" {
qbtrade.Notify(fmt.Sprintf("交易信号未成交,取消订单: %s", symbol))
s.cancelOrders(ctx, symbol)
}
}
s.TradeKLine[symbol] = k
}