-
-
Notifications
You must be signed in to change notification settings - Fork 275
/
tradecollector_callbacks.go
48 lines (38 loc) · 1.3 KB
/
tradecollector_callbacks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Code generated by "callbackgen -type TradeCollector"; DO NOT EDIT.
package core
import (
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
)
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)
}
}
func (c *TradeCollector) OnTrade(cb func(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value)) {
c.tradeCallbacks = append(c.tradeCallbacks, cb)
}
func (c *TradeCollector) EmitTrade(trade types.Trade, profit fixedpoint.Value, netProfit fixedpoint.Value) {
for _, cb := range c.tradeCallbacks {
cb(trade, profit, netProfit)
}
}
func (c *TradeCollector) OnPositionUpdate(cb func(position *types.Position)) {
c.positionUpdateCallbacks = append(c.positionUpdateCallbacks, cb)
}
func (c *TradeCollector) EmitPositionUpdate(position *types.Position) {
for _, cb := range c.positionUpdateCallbacks {
cb(position)
}
}
func (c *TradeCollector) OnProfit(cb func(trade types.Trade, profit *types.Profit)) {
c.profitCallbacks = append(c.profitCallbacks, cb)
}
func (c *TradeCollector) EmitProfit(trade types.Trade, profit *types.Profit) {
for _, cb := range c.profitCallbacks {
cb(trade, profit)
}
}