improve detector name

This commit is contained in:
c9s 2020-06-19 11:21:17 +08:00
parent cbd7a3bd21
commit 377cf2e0ba
2 changed files with 30 additions and 6 deletions

View File

@ -50,9 +50,9 @@ func (e *BinanceExchange) QueryKLines(ctx context.Context, symbol, interval stri
return nil, err
}
var klines []KLine
var kLines []KLine
for _, kline := range resp {
klines = append(klines, KLine{
kLines = append(kLines, KLine{
Symbol: symbol,
Interval: interval,
StartTime: kline.OpenTime,
@ -66,7 +66,7 @@ func (e *BinanceExchange) QueryKLines(ctx context.Context, symbol, interval stri
NumberOfTrades: kline.TradeNum,
})
}
return klines, nil
return kLines, nil
}
func (e *BinanceExchange) QueryTrades(ctx context.Context, market string, startTime time.Time) (trades []Trade, err error) {

View File

@ -16,6 +16,7 @@ func NotZero(v float64) bool {
}
type KLineDetector struct {
Name string `json:"name"`
Interval string `json:"interval"`
MinPriceChange float64 `json:"minPriceChange"`
MaxPriceChange float64 `json:"maxPriceChange"`
@ -34,9 +35,16 @@ type KLineDetector struct {
}
func (d *KLineDetector) SlackAttachment() slack.Attachment {
var name = fmt.Sprintf("Detector %s", d.Interval)
var name = "Detector "
if len(d.Name) > 0 {
name += " " + d.Name
}
name += fmt.Sprintf(" %s", d.Interval)
if d.EnableLookBack {
name = fmt.Sprintf("Detector %s x %d", d.Interval, d.LookBackFrames)
name += fmt.Sprintf(" x %d", d.LookBackFrames)
}
if NotZero(d.MaxPriceChange) {
@ -45,7 +53,23 @@ func (d *KLineDetector) SlackAttachment() slack.Attachment {
name += fmt.Sprintf(" MaxPriceChange %.2f ~ NO LIMIT", d.MinPriceChange)
}
var fields []slack.AttachmentField
var fields = []slack.AttachmentField{
{
Title: "Interval",
Value: d.Interval,
Short: true,
},
{
Title: "MinMaxPriceChange",
Value: formatFloat(d.MinPriceChange, 2),
Short: true,
},
{
Title: "MaxMaxPriceChange",
Value: formatFloat(d.MaxPriceChange, 2),
Short: true,
},
}
if d.EnableMinThickness {
fields = append(fields, slack.AttachmentField{