fix: render basis with explicit sign and absolute delta
Format basis row as +/-$abs(delta) to match the spec and avoid awkward %+s formatting behavior. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package view
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -102,7 +103,11 @@ func RenderRichTokenMessage(in RichTokenMessageInput) string {
|
||||
if in.HasSpot && in.HasFuture && in.SpotPrice > 0 {
|
||||
delta := in.FuturePrice - in.SpotPrice
|
||||
deltaPct := delta / in.SpotPrice * 100
|
||||
rows = append(rows, fmt.Sprintf("🧭 Basis: $%+s (%+.2f%%)", RenderPrice(delta), deltaPct))
|
||||
sign := "+"
|
||||
if delta < 0 {
|
||||
sign = "-"
|
||||
}
|
||||
rows = append(rows, fmt.Sprintf("🧭 Basis: %s$%s (%+.2f%%)", sign, RenderPrice(math.Abs(delta)), deltaPct))
|
||||
}
|
||||
|
||||
if in.HasFuture {
|
||||
|
||||
Reference in New Issue
Block a user