rename callback

This commit is contained in:
kbearXD 2024-04-22 11:07:17 +08:00
parent 547e9ece8f
commit b6e7c48fd5
2 changed files with 7 additions and 7 deletions

View File

@ -100,8 +100,8 @@ type Strategy struct {
// callbacks
common.StatusCallbacks
profitCallbacks []func(*ProfitStats)
positionCallbacks []func(*types.Position)
profitCallbacks []func(*ProfitStats)
positionUpdateCallbacks []func(*types.Position)
}
func (s *Strategy) ID() string {
@ -232,7 +232,7 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
s.updateTakeProfitPrice()
// emit position update
s.EmitPosition(position)
s.EmitPositionUpdate(position)
})
s.OrderExecutor.ActiveMakerOrders().OnFilled(func(o types.Order) {

View File

@ -16,12 +16,12 @@ func (s *Strategy) EmitProfit(profitStats *ProfitStats) {
}
}
func (s *Strategy) OnPosition(cb func(*types.Position)) {
s.positionCallbacks = append(s.positionCallbacks, cb)
func (s *Strategy) OnPositionUpdate(cb func(*types.Position)) {
s.positionUpdateCallbacks = append(s.positionUpdateCallbacks, cb)
}
func (s *Strategy) EmitPosition(position *types.Position) {
for _, cb := range s.positionCallbacks {
func (s *Strategy) EmitPositionUpdate(position *types.Position) {
for _, cb := range s.positionUpdateCallbacks {
cb(position)
}
}