mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
fix: output color output to stderr
This commit is contained in:
parent
28d01486ee
commit
bf6726a529
|
@ -28,15 +28,15 @@ exchangeStrategies:
|
||||||
# disable SL when long
|
# disable SL when long
|
||||||
disableLongStop: false
|
disableLongStop: false
|
||||||
# CCI Stochastic Indicator high filter
|
# CCI Stochastic Indicator high filter
|
||||||
ccistochFilterHigh: 80
|
cciStochFilterHigh: 80
|
||||||
# CCI Stochastic Indicator low filter
|
# CCI Stochastic Indicator low filter
|
||||||
ccistochFilterLow: 20
|
cciStochFilterLow: 20
|
||||||
# ewo change rate histogram's upperbound filter
|
# ewo change rate histogram's upperbound filter
|
||||||
# set to 1 would intend to let all ewo pass
|
# set to 1 would intend to let all ewo pass
|
||||||
ewoChngFilterHigh: 1.
|
ewoChangeFilterHigh: 1.
|
||||||
# ewo change rate histogram's lowerbound filter
|
# ewo change rate histogram's lowerbound filter
|
||||||
# set to 0 would intend to let all ewo pass
|
# set to 0 would intend to let all ewo pass
|
||||||
ewoChngFilterLow: 0.0
|
ewoChangeFilterLow: 0.0
|
||||||
# print record exit point in log messages
|
# print record exit point in log messages
|
||||||
record: false
|
record: false
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
|
@ -34,15 +35,15 @@ type Strategy struct {
|
||||||
Stoploss fixedpoint.Value `json:"stoploss"`
|
Stoploss fixedpoint.Value `json:"stoploss"`
|
||||||
Symbol string `json:"symbol"`
|
Symbol string `json:"symbol"`
|
||||||
Interval types.Interval `json:"interval"`
|
Interval types.Interval `json:"interval"`
|
||||||
UseEma bool `json:"useEma"` // use exponential ma or not
|
UseEma bool `json:"useEma"` // use exponential ma or not
|
||||||
UseSma bool `json:"useSma"` // if UseEma == false, use simple ma or not
|
UseSma bool `json:"useSma"` // if UseEma == false, use simple ma or not
|
||||||
SignalWindow int `json:"sigWin"` // signal window
|
SignalWindow int `json:"sigWin"` // signal window
|
||||||
DisableShortStop bool `json:"disableShortStop"` // disable SL on short
|
DisableShortStop bool `json:"disableShortStop"` // disable SL on short
|
||||||
DisableLongStop bool `json:"disableLongStop"` // disable SL on long
|
DisableLongStop bool `json:"disableLongStop"` // disable SL on long
|
||||||
FilterHigh float64 `json:"ccistochFilterHigh"` // high filter for CCI Stochastic indicator
|
FilterHigh float64 `json:"cciStochFilterHigh"` // high filter for CCI Stochastic indicator
|
||||||
FilterLow float64 `json:"ccistochFilterLow"` // low filter for CCI Stochastic indicator
|
FilterLow float64 `json:"cciStochFilterLow"` // low filter for CCI Stochastic indicator
|
||||||
EwoChangeFilterHigh float64 `json:"ewoChngFilterHigh"` // high filter for ewo histogram
|
EwoChangeFilterHigh float64 `json:"ewoChangeFilterHigh"` // high filter for ewo histogram
|
||||||
EwoChangeFilterLow float64 `json:"ewoChngFilterLow"` // low filter for ewo histogram
|
EwoChangeFilterLow float64 `json:"ewoChangeFilterLow"` // low filter for ewo histogram
|
||||||
|
|
||||||
Record bool `json:"record"` // print record messages on position exit point
|
Record bool `json:"record"` // print record messages on position exit point
|
||||||
|
|
||||||
|
@ -1238,13 +1239,16 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
s.CancelAll(ctx)
|
s.CancelAll(ctx)
|
||||||
|
|
||||||
s.tradeCollector.Process()
|
s.tradeCollector.Process()
|
||||||
color.HiBlue("---- Trade Report (Without Fee) ----")
|
hiblue := color.New(color.FgHiBlue).FprintfFunc()
|
||||||
color.HiBlue("TP:")
|
blue := color.New(color.FgBlue).FprintfFunc()
|
||||||
color.Blue("\tpeak / bottom with atr: %d, avg pnl rate: %f", counterTPfromPeak, percentAvgTPfromPeak)
|
hiyellow := color.New(color.FgHiYellow).FprintfFunc()
|
||||||
color.Blue("\tCCI Stochastic: %d, avg pnl rate: %f", counterTPfromCCI, percentAvgTPfromCCI)
|
hiblue(os.Stderr, "---- Trade Report (Without Fee) ----\n")
|
||||||
color.Blue("\tLongSignal/ShortSignal: %d, avg pnl rate: %f", counterTPfromLongShort, percentAvgTPfromLongShort)
|
hiblue(os.Stderr, "TP:\n")
|
||||||
color.Blue("\tma34 and Atrx2: %d, avg pnl rate: %f", counterTPfromAtr, percentAvgTPfromAtr)
|
blue(os.Stderr, "\tpeak / bottom with atr: %d, avg pnl rate: %f\n", counterTPfromPeak, percentAvgTPfromPeak)
|
||||||
color.Blue("\tActive Order: %d, avg pnl rate: %f", counterTPfromOrder, percentAvgTPfromOrder)
|
blue(os.Stderr, "\tCCI Stochastic: %d, avg pnl rate: %f\n", counterTPfromCCI, percentAvgTPfromCCI)
|
||||||
|
blue(os.Stderr, "\tLongSignal/ShortSignal: %d, avg pnl rate: %f\n", counterTPfromLongShort, percentAvgTPfromLongShort)
|
||||||
|
blue(os.Stderr, "\tma34 and Atrx2: %d, avg pnl rate: %f\n", counterTPfromAtr, percentAvgTPfromAtr)
|
||||||
|
blue(os.Stderr, "\tActive Order: %d, avg pnl rate: %f\n", counterTPfromOrder, percentAvgTPfromOrder)
|
||||||
|
|
||||||
totalTP := counterTPfromPeak + counterTPfromCCI + counterTPfromLongShort + counterTPfromAtr + counterTPfromOrder
|
totalTP := counterTPfromPeak + counterTPfromCCI + counterTPfromLongShort + counterTPfromAtr + counterTPfromOrder
|
||||||
avgProfit := (float64(counterTPfromPeak)*percentAvgTPfromPeak +
|
avgProfit := (float64(counterTPfromPeak)*percentAvgTPfromPeak +
|
||||||
|
@ -1252,17 +1256,17 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
float64(counterTPfromLongShort)*percentAvgTPfromLongShort +
|
float64(counterTPfromLongShort)*percentAvgTPfromLongShort +
|
||||||
float64(counterTPfromAtr)*percentAvgTPfromAtr +
|
float64(counterTPfromAtr)*percentAvgTPfromAtr +
|
||||||
float64(counterTPfromOrder)*percentAvgTPfromOrder) / float64(totalTP)
|
float64(counterTPfromOrder)*percentAvgTPfromOrder) / float64(totalTP)
|
||||||
color.HiBlue("\tSum: %d, avg pnl rate: %f", totalTP, avgProfit)
|
hiblue(os.Stderr, "\tSum: %d, avg pnl rate: %f\n", totalTP, avgProfit)
|
||||||
|
|
||||||
color.HiBlue("SL:")
|
hiblue(os.Stderr, "SL:\n")
|
||||||
color.Blue("\tentry SL: %d, avg pnl rate: -%f", counterSLfromSL, percentAvgSLfromSL)
|
blue(os.Stderr, "\tentry SL: %d, avg pnl rate: -%f\n", counterSLfromSL, percentAvgSLfromSL)
|
||||||
color.Blue("\tActive Order: %d, avg pnl rate: -%f", counterSLfromOrder, percentAvgSLfromOrder)
|
blue(os.Stderr, "\tActive Order: %d, avg pnl rate: -%f\n", counterSLfromOrder, percentAvgSLfromOrder)
|
||||||
|
|
||||||
totalSL := counterSLfromSL + counterSLfromOrder
|
totalSL := counterSLfromSL + counterSLfromOrder
|
||||||
avgLoss := (float64(counterSLfromSL)*percentAvgSLfromSL + float64(counterSLfromOrder)*percentAvgSLfromOrder) / float64(totalSL)
|
avgLoss := (float64(counterSLfromSL)*percentAvgSLfromSL + float64(counterSLfromOrder)*percentAvgSLfromOrder) / float64(totalSL)
|
||||||
color.HiBlue("\tSum: %d, avg pnl rate: -%f", totalSL, avgLoss)
|
hiblue(os.Stderr, "\tSum: %d, avg pnl rate: -%f\n", totalSL, avgLoss)
|
||||||
|
|
||||||
color.HiBlue("WinRate: %f", float64(totalTP)/float64(totalTP+totalSL))
|
hiblue(os.Stderr, "WinRate: %f\n", float64(totalTP)/float64(totalTP+totalSL))
|
||||||
|
|
||||||
maString := "vwema"
|
maString := "vwema"
|
||||||
if s.UseSma {
|
if s.UseSma {
|
||||||
|
@ -1272,23 +1276,23 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
||||||
maString = "ema"
|
maString = "ema"
|
||||||
}
|
}
|
||||||
|
|
||||||
color.HiYellow("----- EWO Settings -------")
|
hiyellow(os.Stderr, "----- EWO Settings -------\n")
|
||||||
color.HiYellow("General:")
|
hiyellow(os.Stderr, "General:\n")
|
||||||
color.HiYellow("\tuseHeikinAshi: %v", s.UseHeikinAshi)
|
hiyellow(os.Stderr, "\tuseHeikinAshi: %v\n", s.UseHeikinAshi)
|
||||||
color.HiYellow("\tstoploss: %v", s.Stoploss)
|
hiyellow(os.Stderr, "\tstoploss: %v\n", s.Stoploss)
|
||||||
color.HiYellow("\tsymbol: %s", s.Symbol)
|
hiyellow(os.Stderr, "\tsymbol: %s\n", s.Symbol)
|
||||||
color.HiYellow("\tinterval: %s", s.Interval)
|
hiyellow(os.Stderr, "\tinterval: %s\n", s.Interval)
|
||||||
color.HiYellow("\tMA type: %s", maString)
|
hiyellow(os.Stderr, "\tMA type: %s\n", maString)
|
||||||
color.HiYellow("\tdisableShortStop: %v", s.DisableShortStop)
|
hiyellow(os.Stderr, "\tdisableShortStop: %v\n", s.DisableShortStop)
|
||||||
color.HiYellow("\tdisableLongStop: %v", s.DisableLongStop)
|
hiyellow(os.Stderr, "\tdisableLongStop: %v\n", s.DisableLongStop)
|
||||||
color.HiYellow("\trecord: %v", s.Record)
|
hiyellow(os.Stderr, "\trecord: %v\n", s.Record)
|
||||||
color.HiYellow("CCI Stochastic:")
|
hiyellow(os.Stderr, "CCI Stochastic:\n")
|
||||||
color.HiYellow("\tccistochFilterHigh: %f", s.FilterHigh)
|
hiyellow(os.Stderr, "\tccistochFilterHigh: %f\n", s.FilterHigh)
|
||||||
color.HiYellow("\tccistochFilterLow: %f", s.FilterLow)
|
hiyellow(os.Stderr, "\tccistochFilterLow: %f\n", s.FilterLow)
|
||||||
color.HiYellow("Ewo && Ewo Histogram:")
|
hiyellow(os.Stderr, "Ewo && Ewo Histogram:\n")
|
||||||
color.HiYellow("\tsigWin: %d", s.SignalWindow)
|
hiyellow(os.Stderr, "\tsigWin: %d\n", s.SignalWindow)
|
||||||
color.HiYellow("\tewoChngFilterHigh: %f", s.EwoChangeFilterHigh)
|
hiyellow(os.Stderr, "\tewoChngFilterHigh: %f\n", s.EwoChangeFilterHigh)
|
||||||
color.HiYellow("\tewoChngFilterLow: %f", s.EwoChangeFilterLow)
|
hiyellow(os.Stderr, "\tewoChngFilterLow: %f\n", s.EwoChangeFilterLow)
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user