mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
strategy:irr fix drawing defer close IO issue
This commit is contained in:
parent
3c52e9e145
commit
600b17460d
|
@ -37,21 +37,21 @@ func (s *Strategy) InitDrawCommands(profit, cumProfit types.Series) {
|
||||||
func (s *Strategy) Draw(profit, cumProfit types.Series) error {
|
func (s *Strategy) Draw(profit, cumProfit types.Series) error {
|
||||||
|
|
||||||
canvas := DrawPNL(s.InstanceID(), profit)
|
canvas := DrawPNL(s.InstanceID(), profit)
|
||||||
f, err := os.Create(s.GraphPNLPath)
|
fPnL, err := os.Create(s.GraphPNLPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot create on path " + s.GraphPNLPath)
|
return fmt.Errorf("cannot create on path " + s.GraphPNLPath)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer fPnL.Close()
|
||||||
if err = canvas.Render(chart.PNG, f); err != nil {
|
if err = canvas.Render(chart.PNG, fPnL); err != nil {
|
||||||
return fmt.Errorf("cannot render pnl")
|
return fmt.Errorf("cannot render pnl")
|
||||||
}
|
}
|
||||||
canvas = DrawCumPNL(s.InstanceID(), cumProfit)
|
canvas = DrawCumPNL(s.InstanceID(), cumProfit)
|
||||||
f, err = os.Create(s.GraphCumPNLPath)
|
fCumPnL, err := os.Create(s.GraphCumPNLPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot create on path " + s.GraphCumPNLPath)
|
return fmt.Errorf("cannot create on path " + s.GraphCumPNLPath)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer fCumPnL.Close()
|
||||||
if err = canvas.Render(chart.PNG, f); err != nil {
|
if err = canvas.Render(chart.PNG, fCumPnL); err != nil {
|
||||||
return fmt.Errorf("cannot render cumpnl")
|
return fmt.Errorf("cannot render cumpnl")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user