adjust pretty print

This commit is contained in:
c9s 2020-08-06 23:51:56 +08:00
parent 8281ec33cb
commit 080cfe25d9

View File

@ -157,44 +157,16 @@ func (k KLine) Color() string {
func (k KLine) SlackAttachment() slack.Attachment { func (k KLine) SlackAttachment() slack.Attachment {
return slack.Attachment{ return slack.Attachment{
Text: fmt.Sprintf("KLine %s %s", k.Symbol, k.Interval), Text: fmt.Sprintf("KLine *%s* %s", k.Symbol, k.Interval),
Color: k.Color(), Color: k.Color(),
Fields: []slack.AttachmentField{ Fields: []slack.AttachmentField{
{ {Title: "Open", Value: k.Open, Short: true},
Title: "Open", {Title: "High", Value: k.High, Short: true},
Value: k.Open, {Title: "Low", Value: k.Low, Short: true},
Short: true, {Title: "Close", Value: k.Close, Short: true},
}, {Title: "Mid", Value: util.FormatFloat(k.Mid(), 2), Short: true},
{ {Title: "Change", Value: util.FormatFloat(k.GetChange(), 2), Short: true},
Title: "High", {Title: "Max Change", Value: util.FormatFloat(k.GetMaxChange(), 2), Short: true},
Value: k.High,
Short: true,
},
{
Title: "Low",
Value: k.Low,
Short: true,
},
{
Title: "Close",
Value: k.Close,
Short: true,
},
{
Title: "Mid",
Value: util.FormatFloat(k.Mid(), 2),
Short: true,
},
{
Title: "Change",
Value: util.FormatFloat(k.GetChange(), 2),
Short: true,
},
{
Title: "Max Change",
Value: util.FormatFloat(k.GetMaxChange(), 2),
Short: true,
},
{ {
Title: "Thickness", Title: "Thickness",
Value: util.FormatFloat(k.GetThickness(), 4), Value: util.FormatFloat(k.GetThickness(), 4),
@ -343,7 +315,7 @@ func (k *KLineWindow) Truncate(size int) {
if start < 0 { if start < 0 {
start = 0 start = 0
} }
*k = (*k)[start : end] *k = (*k)[start:end]
} }
func (k KLineWindow) GetBody() float64 { func (k KLineWindow) GetBody() float64 {
@ -386,34 +358,14 @@ func (k KLineWindow) SlackAttachment() slack.Attachment {
} }
return slack.Attachment{ return slack.Attachment{
Text: fmt.Sprintf("KLine %s %s x %d", first.Symbol, first.Interval, windowSize), Text: fmt.Sprintf("KLine *%s* %s x %d", first.Symbol, first.Interval, windowSize),
Color: k.Color(), Color: k.Color(),
Fields: []slack.AttachmentField{ Fields: []slack.AttachmentField{
{ {Title: "Open", Value: util.FormatFloat(k.GetOpen(), 2), Short: true},
Title: "Open", {Title: "High", Value: util.FormatFloat(k.GetHigh(), 2), Short: true},
Value: util.FormatFloat(k.GetOpen(), 2), {Title: "Low", Value: util.FormatFloat(k.GetLow(), 2), Short: true},
Short: true, {Title: "Close", Value: util.FormatFloat(k.GetClose(), 2), Short: true},
}, {Title: "Mid", Value: util.FormatFloat(k.Mid(), 2), Short: true},
{
Title: "High",
Value: util.FormatFloat(k.GetHigh(), 2),
Short: true,
},
{
Title: "Low",
Value: util.FormatFloat(k.GetLow(), 2),
Short: true,
},
{
Title: "Close",
Value: util.FormatFloat(k.GetClose(), 2),
Short: true,
},
{
Title: "Mid",
Value: util.FormatFloat(k.Mid(), 2),
Short: true,
},
{ {
Title: "Change", Title: "Change",
Value: util.FormatFloat(k.GetChange(), 2), Value: util.FormatFloat(k.GetChange(), 2),
@ -444,4 +396,3 @@ func (k KLineWindow) SlackAttachment() slack.Attachment {
FooterIcon: "", FooterIcon: "",
} }
} }