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"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (c *TradeCollector) OnTrade(cb func(trade types.Trade)) {
|
|
|
|
c.tradeCallbacks = append(c.tradeCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *TradeCollector) EmitTrade(trade types.Trade) {
|
|
|
|
for _, cb := range c.tradeCallbacks {
|
|
|
|
cb(trade)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *TradeCollector) OnPositionUpdate(cb func(position *Position)) {
|
|
|
|
c.positionUpdateCallbacks = append(c.positionUpdateCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *TradeCollector) EmitPositionUpdate(position *Position) {
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|