Skip to content

Commit 22ef28b

Browse files
committed
strategy:harmonic fix drawing defer close IO issue
1 parent ec60c70 commit 22ef28b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/strategy/harmonic/draw.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ func (s *Strategy) InitDrawCommands(profit, cumProfit types.Series) {
3737
func (s *Strategy) Draw(profit, cumProfit types.Series) error {
3838

3939
canvas := DrawPNL(s.InstanceID(), profit)
40-
f, err := os.Create(s.GraphPNLPath)
40+
fPnL, err := os.Create(s.GraphPNLPath)
4141
if err != nil {
4242
return fmt.Errorf("cannot create on path " + s.GraphPNLPath)
4343
}
44-
defer f.Close()
45-
if err = canvas.Render(chart.PNG, f); err != nil {
44+
defer fPnL.Close()
45+
if err = canvas.Render(chart.PNG, fPnL); err != nil {
4646
return fmt.Errorf("cannot render pnl")
4747
}
4848
canvas = DrawCumPNL(s.InstanceID(), cumProfit)
49-
f, err = os.Create(s.GraphCumPNLPath)
49+
fCumPnL, err := os.Create(s.GraphCumPNLPath)
5050
if err != nil {
5151
return fmt.Errorf("cannot create on path " + s.GraphCumPNLPath)
5252
}
53-
defer f.Close()
54-
if err = canvas.Render(chart.PNG, f); err != nil {
53+
defer fCumPnL.Close()
54+
if err = canvas.Render(chart.PNG, fCumPnL); err != nil {
5555
return fmt.Errorf("cannot render cumpnl")
5656
}
5757

0 commit comments

Comments
 (0)