[update] 去掉持久化
This commit is contained in:
parent
ae775303f6
commit
855ce2324d
|
@ -1,10 +1,10 @@
|
||||||
persistence:
|
#persistence:
|
||||||
json:
|
# json:
|
||||||
directory: var/data
|
# directory: var/data
|
||||||
redis:
|
# redis:
|
||||||
host: 127.0.0.1
|
# host: 127.0.0.1
|
||||||
port: 6379
|
# port: 6379
|
||||||
db: 0
|
# db: 0
|
||||||
|
|
||||||
sessions:
|
sessions:
|
||||||
binance_futures:
|
binance_futures:
|
||||||
|
|
|
@ -112,6 +112,9 @@ func (s *Strategy) cancelOrders(ctx context.Context, symbol string) {
|
||||||
if err := s.orderExecutors[symbol].GracefulCancel(ctx); err != nil {
|
if err := s.orderExecutors[symbol].GracefulCancel(ctx); err != nil {
|
||||||
log.WithError(err).Errorf("failed to cancel orders")
|
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) {
|
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] = qbtrade.NewGeneralOrderExecutor(session, symbol, ID, s.InstanceID(), s.Positions[symbol])
|
||||||
s.orderExecutors[symbol].BindEnvironment(s.Environment)
|
s.orderExecutors[symbol].BindEnvironment(s.Environment)
|
||||||
_ = s.orderExecutors[symbol].GracefulCancel(ctx)
|
_ = s.orderExecutors[symbol].GracefulCancel(ctx)
|
||||||
s.orderExecutors[symbol].BindProfitStats(s.ProfitStats[symbol])
|
//s.orderExecutors[symbol].BindProfitStats(s.ProfitStats[symbol])
|
||||||
s.orderExecutors[symbol].TradeCollector().OnPositionUpdate(func(position *types.Position) {
|
//s.orderExecutors[symbol].TradeCollector().OnPositionUpdate(func(position *types.Position) {
|
||||||
qbtrade.Sync(ctx, s)
|
// qbtrade.Sync(ctx, s)
|
||||||
})
|
//})
|
||||||
s.orderExecutors[symbol].Bind()
|
s.orderExecutors[symbol].Bind()
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
|
@ -352,7 +355,10 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor qbtrade.OrderExecutor,
|
||||||
|
|
||||||
if !s.Traded[symbol] {
|
if !s.Traded[symbol] {
|
||||||
// 如若在下一根k线未成交 则取消订单
|
// 如若在下一根k线未成交 则取消订单
|
||||||
s.cancelOrders(ctx, symbol)
|
if s.TradeType[symbol] != "" {
|
||||||
|
qbtrade.Notify(fmt.Sprintf("交易信号未成交,取消订单: %s", symbol))
|
||||||
|
s.cancelOrders(ctx, symbol)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s.TradeKLine[symbol] = k
|
s.TradeKLine[symbol] = k
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user