qbtrade/pkg/strategy/dca2/strategy_callbacks.go

28 lines
632 B
Go
Raw Normal View History

2024-06-27 14:42:38 +00:00
// Code generated by "callbackgen -type Strategy"; DO NOT EDIT.
package dca2
import (
"git.qtrade.icu/lychiyu/qbtrade/pkg/types"
)
func (s *Strategy) OnProfit(cb func(*ProfitStats)) {
s.profitCallbacks = append(s.profitCallbacks, cb)
}
func (s *Strategy) EmitProfit(profitStats *ProfitStats) {
for _, cb := range s.profitCallbacks {
cb(profitStats)
}
}
func (s *Strategy) OnPositionUpdate(cb func(*types.Position)) {
s.positionUpdateCallbacks = append(s.positionUpdateCallbacks, cb)
}
func (s *Strategy) EmitPositionUpdate(position *types.Position) {
for _, cb := range s.positionUpdateCallbacks {
cb(position)
}
}