2023-12-27 08:13:34 +00:00
|
|
|
// Code generated by "callbackgen -type Strategy"; DO NOT EDIT.
|
|
|
|
|
|
|
|
package dca2
|
|
|
|
|
2024-04-19 08:24:40 +00:00
|
|
|
import (
|
|
|
|
"github.com/c9s/bbgo/pkg/types"
|
|
|
|
)
|
|
|
|
|
2024-01-02 09:16:47 +00:00
|
|
|
func (s *Strategy) OnProfit(cb func(*ProfitStats)) {
|
2023-12-27 08:13:34 +00:00
|
|
|
s.profitCallbacks = append(s.profitCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2024-01-02 09:16:47 +00:00
|
|
|
func (s *Strategy) EmitProfit(profitStats *ProfitStats) {
|
2023-12-27 08:13:34 +00:00
|
|
|
for _, cb := range s.profitCallbacks {
|
|
|
|
cb(profitStats)
|
|
|
|
}
|
|
|
|
}
|
2024-04-19 08:24:40 +00:00
|
|
|
|
2024-04-22 03:07:17 +00:00
|
|
|
func (s *Strategy) OnPositionUpdate(cb func(*types.Position)) {
|
|
|
|
s.positionUpdateCallbacks = append(s.positionUpdateCallbacks, cb)
|
2024-04-19 08:24:40 +00:00
|
|
|
}
|
|
|
|
|
2024-04-22 03:07:17 +00:00
|
|
|
func (s *Strategy) EmitPositionUpdate(position *types.Position) {
|
|
|
|
for _, cb := range s.positionUpdateCallbacks {
|
2024-04-19 08:24:40 +00:00
|
|
|
cb(position)
|
|
|
|
}
|
|
|
|
}
|