pivotshort: log submit order error

This commit is contained in:
c9s 2022-09-08 23:19:14 +08:00
parent edc8c132d5
commit 90f3727d68
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -220,8 +220,8 @@ func (s *FailedBreakHigh) Bind(session *bbgo.ExchangeSession, orderExecutor *bbg
} }
if s.MarketOrder { if s.MarketOrder {
bbgo.Notify("%s price %f failed breaking the previous high %f with ratio %f, submitting market sell to open a short position", symbol, kline.Close.Float64(), previousHigh.Float64(), s.Ratio.Float64()) bbgo.Notify("%s price %f failed breaking the previous high %f with ratio %f, submitting market sell %f to open a short position", symbol, kline.Close.Float64(), previousHigh.Float64(), s.Ratio.Float64(), quantity.Float64())
_, _ = s.orderExecutor.SubmitOrders(ctx, types.SubmitOrder{ _, err := s.orderExecutor.SubmitOrders(ctx, types.SubmitOrder{
Symbol: s.Symbol, Symbol: s.Symbol,
Side: types.SideTypeSell, Side: types.SideTypeSell,
Type: types.OrderTypeMarket, Type: types.OrderTypeMarket,
@ -229,12 +229,15 @@ func (s *FailedBreakHigh) Bind(session *bbgo.ExchangeSession, orderExecutor *bbg
MarginSideEffect: types.SideEffectTypeMarginBuy, MarginSideEffect: types.SideEffectTypeMarginBuy,
Tag: "FailedBreakHighMarket", Tag: "FailedBreakHighMarket",
}) })
if err != nil {
bbgo.Notify(err.Error())
}
} else { } else {
sellPrice := previousHigh sellPrice := previousHigh
bbgo.Notify("%s price %f failed breaking the previous high %f with ratio %f, submitting limit sell @ %f", symbol, kline.Close.Float64(), previousHigh.Float64(), s.Ratio.Float64(), sellPrice.Float64()) bbgo.Notify("%s price %f failed breaking the previous high %f with ratio %f, submitting limit sell @ %f", symbol, kline.Close.Float64(), previousHigh.Float64(), s.Ratio.Float64(), sellPrice.Float64())
_, _ = s.orderExecutor.SubmitOrders(ctx, types.SubmitOrder{ _, err := s.orderExecutor.SubmitOrders(ctx, types.SubmitOrder{
Symbol: kline.Symbol, Symbol: kline.Symbol,
Side: types.SideTypeSell, Side: types.SideTypeSell,
Type: types.OrderTypeLimit, Type: types.OrderTypeLimit,
@ -243,6 +246,10 @@ func (s *FailedBreakHigh) Bind(session *bbgo.ExchangeSession, orderExecutor *bbg
MarginSideEffect: types.SideEffectTypeMarginBuy, MarginSideEffect: types.SideEffectTypeMarginBuy,
Tag: "FailedBreakHighLimit", Tag: "FailedBreakHighLimit",
}) })
if err != nil {
bbgo.Notify(err.Error())
}
} }
})) }))
} }