2021-06-24 07:38:44 +00:00
|
|
|
// Code generated by "callbackgen -type TradeCollector"; DO NOT EDIT.
|
|
|
|
|
|
|
|
package bbgo
|
|
|
|
|
|
|
|
import (
|
2021-06-24 11:29:21 +00:00
|
|
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
2021-06-24 07:38:44 +00:00
|
|
|
"github.com/c9s/bbgo/pkg/types"
|
|
|
|
)
|
|
|
|
|
2022-01-09 07:39:59 +00:00
|
|
|
func (c *TradeCollector) OnRecover(cb func(trade types.Trade)) {
|
|
|
|
c.recoverCallbacks = append(c.recoverCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *TradeCollector) EmitRecover(trade types.Trade) {
|
|
|
|
for _, cb := range c.recoverCallbacks {
|
|
|
|
cb(trade)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-11 13:27:45 +00:00
|
|
|
func (c *TradeCollector) OnTrade(cb func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value)) {
|
2021-06-24 07:38:44 +00:00
|
|
|
c.tradeCallbacks = append(c.tradeCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2022-03-11 13:27:45 +00:00
|
|
|
func (c *TradeCollector) EmitTrade(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value) {
|
2021-06-24 07:38:44 +00:00
|
|
|
for _, cb := range c.tradeCallbacks {
|
2022-03-11 13:27:45 +00:00
|
|
|
cb(trade, profit, netProfit)
|
2021-06-24 07:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-11 11:16:16 +00:00
|
|
|
func (c *TradeCollector) OnPositionUpdate(cb func(position *types.Position)) {
|
2021-06-24 07:38:44 +00:00
|
|
|
c.positionUpdateCallbacks = append(c.positionUpdateCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2021-12-11 11:16:16 +00:00
|
|
|
func (c *TradeCollector) EmitPositionUpdate(position *types.Position) {
|
2021-06-24 07:38:44 +00:00
|
|
|
for _, cb := range c.positionUpdateCallbacks {
|
|
|
|
cb(position)
|
|
|
|
}
|
|
|
|
}
|
2021-06-24 11:29:21 +00:00
|
|
|
|
2022-06-18 04:30:42 +00:00
|
|
|
func (c *TradeCollector) OnProfit(cb func(trade types.Trade, profit *types.Profit)) {
|
2021-06-24 11:29:21 +00:00
|
|
|
c.profitCallbacks = append(c.profitCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2022-06-18 04:30:42 +00:00
|
|
|
func (c *TradeCollector) EmitProfit(trade types.Trade, profit *types.Profit) {
|
2021-06-24 11:29:21 +00:00
|
|
|
for _, cb := range c.profitCallbacks {
|
2022-06-18 04:30:42 +00:00
|
|
|
cb(trade, profit)
|
2021-06-24 11:29:21 +00:00
|
|
|
}
|
|
|
|
}
|