@@ -11,23 +11,36 @@ import (
11
11
"github.com/wcharczuk/go-chart/v2"
12
12
)
13
13
14
- func (s * Strategy ) InitDrawCommands (profit , cumProfit types.Series ) {
15
- bbgo .RegisterCommand ("/pnl" , "Draw PNL(%) per trade" , func (reply interact.Reply ) {
14
+ func (s * Strategy ) InitDrawCommands (profit , cumProfit , cumProfitDollar types.Series ) {
15
+ bbgo .RegisterCommand ("/rt" , "Draw Return Rate(%) Per Trade" , func (reply interact.Reply ) {
16
+
16
17
canvas := DrawPNL (s .InstanceID (), profit )
17
18
var buffer bytes.Buffer
18
19
if err := canvas .Render (chart .PNG , & buffer ); err != nil {
19
- log .WithError (err ).Errorf ("cannot render pnl in drift " )
20
- reply .Message (fmt .Sprintf ("[error] cannot render pnl in ewo : %v" , err ))
20
+ log .WithError (err ).Errorf ("cannot render return in irr " )
21
+ reply .Message (fmt .Sprintf ("[error] cannot render return in irr : %v" , err ))
21
22
return
22
23
}
23
24
bbgo .SendPhoto (& buffer )
24
25
})
25
- bbgo .RegisterCommand ("/cumpnl" , "Draw Cummulative PNL(Quote)" , func (reply interact.Reply ) {
26
+ bbgo .RegisterCommand ("/nav" , "Draw Net Assets Value" , func (reply interact.Reply ) {
27
+
26
28
canvas := DrawCumPNL (s .InstanceID (), cumProfit )
27
29
var buffer bytes.Buffer
28
30
if err := canvas .Render (chart .PNG , & buffer ); err != nil {
29
- log .WithError (err ).Errorf ("cannot render cumpnl in drift" )
30
- reply .Message (fmt .Sprintf ("[error] canot render cumpnl in drift: %v" , err ))
31
+ log .WithError (err ).Errorf ("cannot render nav in irr" )
32
+ reply .Message (fmt .Sprintf ("[error] canot render nav in irr: %v" , err ))
33
+ return
34
+ }
35
+ bbgo .SendPhoto (& buffer )
36
+ })
37
+ bbgo .RegisterCommand ("/pnl" , "Draw Cumulative Profit & Loss" , func (reply interact.Reply ) {
38
+
39
+ canvas := DrawCumPNL (s .InstanceID (), cumProfitDollar )
40
+ var buffer bytes.Buffer
41
+ if err := canvas .Render (chart .PNG , & buffer ); err != nil {
42
+ log .WithError (err ).Errorf ("cannot render pnl in irr" )
43
+ reply .Message (fmt .Sprintf ("[error] canot render pnl in irr: %v" , err ))
31
44
return
32
45
}
33
46
bbgo .SendPhoto (& buffer )
@@ -77,7 +90,7 @@ func DrawPNL(instanceID string, profit types.Series) *types.Canvas {
77
90
78
91
func DrawCumPNL (instanceID string , cumProfit types.Series ) * types.Canvas {
79
92
canvas := types .NewCanvas (instanceID )
80
- canvas .PlotRaw ("cummulative pnl" , cumProfit , cumProfit .Length ())
93
+ canvas .PlotRaw ("cumulative pnl" , cumProfit , cumProfit .Length ())
81
94
canvas .YAxis = chart.YAxis {
82
95
ValueFormatter : func (v interface {}) string {
83
96
if vf , isFloat := v .(float64 ); isFloat {
0 commit comments