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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-30 07:15:44 +00:00
|
|
|
func (c *TradeCollector) OnPositionUpdate(cb func(position types.PositionInterface)) {
|
2021-06-24 07:38:44 +00:00
|
|
|
c.positionUpdateCallbacks = append(c.positionUpdateCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2022-05-30 07:15:44 +00:00
|
|
|
func (c *TradeCollector) EmitPositionUpdate(position types.PositionInterface) {
|
2021-06-24 07:38:44 +00:00
|
|
|
for _, cb := range c.positionUpdateCallbacks {
|
|
|
|
cb(position)
|
|
|
|
}
|
|
|
|
}
|
2021-06-24 11:29:21 +00:00
|
|
|
|
|
|
|
func (c *TradeCollector) OnProfit(cb func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value)) {
|
|
|
|
c.profitCallbacks = append(c.profitCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *TradeCollector) EmitProfit(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value) {
|
|
|
|
for _, cb := range c.profitCallbacks {
|
|
|
|
cb(trade, profit, netProfit)
|
|
|
|
}
|
|
|
|
}
|