diff --git a/cointop/cache.go b/cointop/cache.go
index 74925e1..755eed5 100644
--- a/cointop/cache.go
+++ b/cointop/cache.go
@@ -10,10 +10,24 @@ import (
// CacheKey returns cached value given key
func (ct *Cointop) CacheKey(key string) string {
- log.Debug("CacheKey()")
return strings.ToLower(fmt.Sprintf("%s_%s", ct.apiChoice, key))
}
+// CompositeCacheKey returns a CacheKey for a coin (or globaldata)
+func (ct *Cointop) CompositeCacheKey(symbol string, name string, convert string, chartRange string) string {
+ keyname := symbol
+ if name != "" {
+ keyname += "-" + name
+ }
+ if convert != "" {
+ keyname += "_" + convert
+ }
+ if chartRange != "" {
+ keyname += "_" + strings.Replace(chartRange, " ", "", -1) // "All Time" contains space
+ }
+ return ct.CacheKey(keyname)
+}
+
// CacheAllCoinsSlugMap writes the coins map to the memory and disk cache
func (ct *Cointop) CacheAllCoinsSlugMap() {
log.Debug("CacheAllCoinsSlugMap()")
diff --git a/cointop/chart.go b/cointop/chart.go
index 9c64a2a..19fd5c8 100644
--- a/cointop/chart.go
+++ b/cointop/chart.go
@@ -4,7 +4,6 @@ import (
"fmt"
"math"
"sort"
- "strings"
"sync"
"time"
@@ -135,7 +134,7 @@ func (ct *Cointop) ChartPoints(symbol string, name string) error {
if keyname == "" {
keyname = "globaldata"
}
- cachekey := ct.CacheKey(fmt.Sprintf("%s_%s", keyname, strings.Replace(ct.State.selectedChartRange, " ", "", -1)))
+ cachekey := ct.CompositeCacheKey(keyname, name, ct.State.currencyConversion, ct.State.selectedChartRange)
cached, found := ct.cache.Get(cachekey)
if found {
@@ -241,7 +240,7 @@ func (ct *Cointop) PortfolioChart() error {
}
var cacheData [][]float64 // [][time,value]
- cachekey := strings.ToLower(fmt.Sprintf("%s_%s_%s", p.Symbol, convert, strings.Replace(selectedChartRange, " ", "", -1)))
+ cachekey := ct.CompositeCacheKey(p.Symbol, p.Name, convert, selectedChartRange)
cached, found := ct.cache.Get(cachekey)
if found {
// cache hit
@@ -318,6 +317,16 @@ func (ct *Cointop) PortfolioChart() error {
}
}
+ // Scale Portfolio Balances to hide value
+ if ct.State.hidePortfolioBalances {
+ var lastPrice = data[len(data)-1]
+ if lastPrice > 0.0 {
+ for i, price := range data {
+ data[i] = 100 * price / lastPrice
+ }
+ }
+ }
+
chart.SetData(data)
ct.State.chartPoints = chart.GetChartPoints(maxX)
diff --git a/cointop/cointop.go b/cointop/cointop.go
index dbbaa89..ebbd4b0 100644
--- a/cointop/cointop.go
+++ b/cointop/cointop.go
@@ -445,7 +445,7 @@ func NewCointop(config *Config) (*Cointop, error) {
})
var globaldata []float64
- chartcachekey := ct.CacheKey(fmt.Sprintf("%s_%s", "globaldata", strings.Replace(ct.State.selectedChartRange, " ", "", -1)))
+ chartcachekey := ct.CompositeCacheKey("globaldata", "", "", ct.State.selectedChartRange)
if ct.filecache != nil {
ct.filecache.Get(chartcachekey, &globaldata)
}
diff --git a/cointop/conversion.go b/cointop/conversion.go
index 334b54a..ec6c053 100644
--- a/cointop/conversion.go
+++ b/cointop/conversion.go
@@ -56,53 +56,55 @@ var FiatCurrencyNames = map[string]string{
// CryptocurrencyNames is a map of cryptocurrency symbols to name
var CryptocurrencyNames = map[string]string{
- "BTC": "Bitcoin",
- "ETH": "Ethereum",
+ "BTC": "Bitcoin",
+ "ETH": "Ethereum",
+ "SATS": "Satoshi",
}
// CurrencySymbolMap is map of fiat currency symbols to names.
// Keep these in alphabetical order.
var CurrencySymbolMap = map[string]string{
- "AUD": "$",
- "BGN": "Лв.",
- "BRL": "R$",
- "BTC": "Ƀ",
- "CAD": "$",
- "CFH": "₣",
- "CLP": "$",
- "CNY": "¥",
- "CZK": "Kč",
- "DKK": "Kr",
- "ETH": "Ξ",
- "EUR": "€",
- "GBP": "£",
- "HKD": "$",
- "HRK": "kn",
- "HUF": "Ft",
- "IDR": "Rp.",
- "ILS": "₪",
- "INR": "₹",
- "ISK": "kr",
- "JPY": "¥",
- "KRW": "₩",
- "MXN": "$",
- "MYR": "RM",
- "NOK": "kr",
- "NZD": "$",
- "PHP": "₱",
- "PKR": "₨",
- "PLN": "zł",
- "RON": "lei",
- "RUB": "Ꝑ",
- "SEK": "kr",
- "SGD": "S$",
- "THB": "฿",
- "TRY": "₺",
- "TWD": "NT$",
- "UAH": "₴",
- "USD": "$",
- "VND": "₫",
- "ZAR": "R",
+ "AUD": "$",
+ "BGN": "Лв.",
+ "BRL": "R$",
+ "BTC": "Ƀ",
+ "CAD": "$",
+ "CFH": "₣",
+ "CLP": "$",
+ "CNY": "¥",
+ "CZK": "Kč",
+ "DKK": "Kr",
+ "ETH": "Ξ",
+ "EUR": "€",
+ "GBP": "£",
+ "HKD": "$",
+ "HRK": "kn",
+ "HUF": "Ft",
+ "IDR": "Rp.",
+ "ILS": "₪",
+ "INR": "₹",
+ "ISK": "kr",
+ "JPY": "¥",
+ "KRW": "₩",
+ "MXN": "$",
+ "MYR": "RM",
+ "NOK": "kr",
+ "NZD": "$",
+ "PHP": "₱",
+ "PKR": "₨",
+ "PLN": "zł",
+ "RON": "lei",
+ "RUB": "Ꝑ",
+ "SEK": "kr",
+ "SGD": "S$",
+ "SATS": "丰",
+ "THB": "฿",
+ "TRY": "₺",
+ "TWD": "NT$",
+ "UAH": "₴",
+ "USD": "$",
+ "VND": "₫",
+ "ZAR": "R",
}
var alphanumericcharacters = []rune{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}
diff --git a/cointop/layout.go b/cointop/layout.go
index f056130..3800b24 100644
--- a/cointop/layout.go
+++ b/cointop/layout.go
@@ -1,9 +1,6 @@
package cointop
import (
- "fmt"
- "strings"
-
log "github.com/sirupsen/logrus"
)
@@ -99,7 +96,7 @@ func (ct *Cointop) layout() error {
ct.Views.Chart.SetBgColor(ct.colorscheme.GocuiBgColor(ct.Views.Chart.Name()))
go func() {
ct.UpdateChart()
- cachekey := strings.ToLower(fmt.Sprintf("%s_%s", "globaldata", strings.Replace(ct.State.selectedChartRange, " ", "", -1)))
+ cachekey := ct.CompositeCacheKey("globaldata", "", "", ct.State.selectedChartRange)
_, found := ct.cache.Get(cachekey)
if found {
ct.cache.Delete(cachekey)
diff --git a/cointop/marketbar.go b/cointop/marketbar.go
index 3adf857..75dc841 100644
--- a/cointop/marketbar.go
+++ b/cointop/marketbar.go
@@ -71,6 +71,7 @@ func (ct *Cointop) UpdateMarketbar() error {
color24h = ct.colorscheme.MarketbarChangeDownSprintf()
arrow = "▼"
}
+ percentChange24Hstr := color24h(fmt.Sprintf("%.2f%%%s", percentChange24H, arrow))
chartInfo := ""
if !ct.State.hideChart {
@@ -84,13 +85,14 @@ func (ct *Cointop) UpdateMarketbar() error {
totalstr = fmt.Sprintf("%s%s", ct.CurrencySymbol(), totalstr)
if ct.State.hidePortfolioBalances {
totalstr = HiddenBalanceChars
+ percentChange24Hstr = HiddenBalanceChars
}
content = fmt.Sprintf(
"%sTotal Portfolio Value: %s • 24H: %s",
chartInfo,
ct.colorscheme.MarketBarLabelActive(totalstr),
- color24h(fmt.Sprintf("%.2f%%%s", percentChange24H, arrow)),
+ percentChange24Hstr,
)
} else {
ct.State.marketBarHeight = 1
@@ -100,7 +102,7 @@ func (ct *Cointop) UpdateMarketbar() error {
var market types.GlobalMarketData
var err error
- cachekey := ct.CacheKey("market")
+ cachekey := ct.CompositeCacheKey("market", "", ct.State.currencyConversion, "")
cached, found := ct.cache.Get(cachekey)
if found {
diff --git a/cointop/table_header.go b/cointop/table_header.go
index e42ae4a..6e4053a 100644
--- a/cointop/table_header.go
+++ b/cointop/table_header.go
@@ -183,7 +183,12 @@ func (ct *Cointop) UpdateTableHeader() error {
leftAlign := ct.GetTableColumnAlignLeft(col)
switch col {
case "price", "balance":
- label = ct.CurrencySymbol() + label
+ spacing := ""
+ // Add an extra space because "satoshi" UTF-8 chracter overlaps text on right
+ if ct.State.currencyConversion == "SATS" {
+ spacing = " "
+ }
+ label = fmt.Sprintf("%s%s%s", ct.CurrencySymbol(), spacing, label)
}
if leftAlign {
label = label + arrow
diff --git a/docs/content/faq.md b/docs/content/faq.md
index f86bb18..dc4ee5f 100644
--- a/docs/content/faq.md
+++ b/docs/content/faq.md
@@ -187,7 +187,7 @@ draft: false
You can run cointop with the `--hide-portfolio-balances` flag to hide portfolio balances or use the keyboard shortcut Ctrl+space on the portfolio page to toggle hide/show.
-
+
## I'm getting question marks or weird symbols instead of the correct characters.
diff --git a/pkg/api/impl/coingecko/coingecko.go b/pkg/api/impl/coingecko/coingecko.go
index 6bd7b08..5ffbd16 100644
--- a/pkg/api/impl/coingecko/coingecko.go
+++ b/pkg/api/impl/coingecko/coingecko.go
@@ -268,6 +268,7 @@ func (s *Service) SupportedCurrencies() []string {
"PLN",
"RUB",
"SAR",
+ "SATS",
"SEK",
"SGD",
"THB",