mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
grid2: add newOrderUpdateHandler and send profit to notification
This commit is contained in:
parent
c2133a1712
commit
051aa19989
|
@ -349,6 +349,9 @@ func (s *Strategy) processFilledOrder(o types.Order) {
|
|||
s.logger.Infof("GENERATED GRID PROFIT: %+v", profit)
|
||||
s.GridProfitStats.AddProfit(profit)
|
||||
|
||||
bbgo.Notify(profit)
|
||||
bbgo.Notify(s.GridProfitStats)
|
||||
|
||||
case types.SideTypeBuy:
|
||||
newSide = types.SideTypeSell
|
||||
if !s.ProfitSpread.IsZero() {
|
||||
|
@ -652,6 +655,13 @@ func (s *Strategy) newTriggerPriceHandler(ctx context.Context, session *bbgo.Exc
|
|||
})
|
||||
}
|
||||
|
||||
func (s *Strategy) newOrderUpdateHandler(ctx context.Context, session *bbgo.ExchangeSession) func(o types.Order) {
|
||||
return func(o types.Order) {
|
||||
s.handleOrderFilled(o)
|
||||
bbgo.Sync(ctx, s)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Strategy) newStopLossPriceHandler(ctx context.Context, session *bbgo.ExchangeSession) types.KLineCallback {
|
||||
return types.KLineWith(s.Symbol, types.Interval1m, func(k types.KLine) {
|
||||
if s.StopLossPrice.Compare(k.Low) < 0 {
|
||||
|
@ -1034,10 +1044,7 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
|||
orderExecutor.TradeCollector().OnPositionUpdate(func(position *types.Position) {
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
orderExecutor.ActiveMakerOrders().OnFilled(func(o types.Order) {
|
||||
s.handleOrderFilled(o)
|
||||
bbgo.Sync(context.Background(), s)
|
||||
})
|
||||
orderExecutor.ActiveMakerOrders().OnFilled(s.newOrderUpdateHandler(ctx, session))
|
||||
|
||||
s.orderExecutor = orderExecutor
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user