|
|
@ -5,13 +5,13 @@ |
|
|
|
package mop |
|
|
|
package mop |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
`bytes` |
|
|
|
"bytes" |
|
|
|
`fmt` |
|
|
|
"fmt" |
|
|
|
`reflect` |
|
|
|
"reflect" |
|
|
|
`regexp` |
|
|
|
"regexp" |
|
|
|
`strings` |
|
|
|
"strings" |
|
|
|
`text/template` |
|
|
|
"text/template" |
|
|
|
`time` |
|
|
|
"time" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Column describes formatting rules for individual column within the list
|
|
|
|
// Column describes formatting rules for individual column within the list
|
|
|
@ -53,6 +53,8 @@ func NewLayout() *Layout { |
|
|
|
{9, `Dividend`, `Dividend`, zero}, |
|
|
|
{9, `Dividend`, `Dividend`, zero}, |
|
|
|
{9, `Yield`, `Yield`, percent}, |
|
|
|
{9, `Yield`, `Yield`, percent}, |
|
|
|
{11, `MarketCap`, `MktCap`, currency}, |
|
|
|
{11, `MarketCap`, `MktCap`, currency}, |
|
|
|
|
|
|
|
{13, `PreOpen`, `PreMktChg%`, last}, |
|
|
|
|
|
|
|
{13, `AfterHours`, `AfterMktChg%`, last}, |
|
|
|
} |
|
|
|
} |
|
|
|
layout.regex = regexp.MustCompile(`(\.\d+)[BMK]?$`) |
|
|
|
layout.regex = regexp.MustCompile(`(\.\d+)[BMK]?$`) |
|
|
|
layout.marketTemplate = buildMarketTemplate() |
|
|
|
layout.marketTemplate = buildMarketTemplate() |
|
|
@ -208,7 +210,7 @@ func buildQuotesTemplate() *template.Template { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{{.Header}} |
|
|
|
{{.Header}} |
|
|
|
{{range.Stocks}}{{if .Advancing}}<green>{{end}}{{.Ticker}}{{.LastTrade}}{{.Change}}{{.ChangePct}}{{.Open}}{{.Low}}{{.High}}{{.Low52}}{{.High52}}{{.Volume}}{{.AvgVolume}}{{.PeRatio}}{{.Dividend}}{{.Yield}}{{.MarketCap}}</> |
|
|
|
{{range.Stocks}}{{if .Advancing}}<green>{{end}}{{.Ticker}}{{.LastTrade}}{{.Change}}{{.ChangePct}}{{.Open}}{{.Low}}{{.High}}{{.Low52}}{{.High52}}{{.Volume}}{{.AvgVolume}}{{.PeRatio}}{{.Dividend}}{{.Yield}}{{.MarketCap}}{{.PreOpen}}{{.AfterHours}}</> |
|
|
|
{{end}}` |
|
|
|
{{end}}` |
|
|
|
|
|
|
|
|
|
|
|
return template.Must(template.New(`quotes`).Parse(markup)) |
|
|
|
return template.Must(template.New(`quotes`).Parse(markup)) |
|
|
@ -298,7 +300,7 @@ func currency(str... string) string { |
|
|
|
} |
|
|
|
} |
|
|
|
//default to $
|
|
|
|
//default to $
|
|
|
|
symbol := "$" |
|
|
|
symbol := "$" |
|
|
|
switch (str[1]){ |
|
|
|
switch str[1] { |
|
|
|
case "JPY": |
|
|
|
case "JPY": |
|
|
|
symbol = "¥" |
|
|
|
symbol = "¥" |
|
|
|
break |
|
|
|
break |
|
|
|