issue72, corrected pct parsing for pre and after market

master
Matthew Kindzerske 4 years ago
parent 3e23d86bb0
commit 772652ff7b
  1. 4
      layout.go
  2. 17
      sorter.go

@ -60,8 +60,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, `PreOpen`, `PreMktChg%`, percent},
{13, `AfterHours`, `AfterMktChg%`, last}, {13, `AfterHours`, `AfterMktChg%`, percent},
} }
layout.regex = regexp.MustCompile(`(\.\d+)[BMK]?$`) layout.regex = regexp.MustCompile(`(\.\d+)[BMK]?$`)
layout.marketTemplate = buildMarketTemplate() layout.marketTemplate = buildMarketTemplate()

@ -73,7 +73,9 @@ func (list byChangePctAsc) Less(i, j int) bool {
func (list byOpenAsc) Less(i, j int) bool { func (list byOpenAsc) Less(i, j int) bool {
return list.sortable[i].Open < list.sortable[j].Open return list.sortable[i].Open < list.sortable[j].Open
} }
func (list byLowAsc) Less(i, j int) bool { return list.sortable[i].Low < list.sortable[j].Low } func (list byLowAsc) Less(i, j int) bool {
return list.sortable[i].Low < list.sortable[j].Low
}
func (list byHighAsc) Less(i, j int) bool { func (list byHighAsc) Less(i, j int) bool {
return list.sortable[i].High < list.sortable[j].High return list.sortable[i].High < list.sortable[j].High
} }
@ -102,12 +104,13 @@ func (list byMarketCapAsc) Less(i, j int) bool {
return m(list.sortable[i].MarketCap) < m(list.sortable[j].MarketCap) return m(list.sortable[i].MarketCap) < m(list.sortable[j].MarketCap)
} }
func (list byPreOpenAsc) Less(i, j int) bool { func (list byPreOpenAsc) Less(i, j int) bool {
return m(list.sortable[i].PreOpen) < m(list.sortable[j].PreOpen) return c(list.sortable[i].PreOpen) < c(list.sortable[j].PreOpen)
} }
func (list byAfterHoursAsc) Less(i, j int) bool { func (list byAfterHoursAsc) Less(i, j int) bool {
return m(list.sortable[i].AfterHours) < m(list.sortable[j].AfterHours) return c(list.sortable[i].AfterHours) < c(list.sortable[j].AfterHours)
} }
func (list byTickerDesc) Less(i, j int) bool { func (list byTickerDesc) Less(i, j int) bool {
return list.sortable[j].Ticker < list.sortable[i].Ticker return list.sortable[j].Ticker < list.sortable[i].Ticker
} }
@ -123,7 +126,9 @@ func (list byChangePctDesc) Less(i, j int) bool {
func (list byOpenDesc) Less(i, j int) bool { func (list byOpenDesc) Less(i, j int) bool {
return list.sortable[j].Open < list.sortable[i].Open return list.sortable[j].Open < list.sortable[i].Open
} }
func (list byLowDesc) Less(i, j int) bool { return list.sortable[j].Low < list.sortable[i].Low } func (list byLowDesc) Less(i, j int) bool {
return list.sortable[j].Low < list.sortable[i].Low
}
func (list byHighDesc) Less(i, j int) bool { func (list byHighDesc) Less(i, j int) bool {
return list.sortable[j].High < list.sortable[i].High return list.sortable[j].High < list.sortable[i].High
} }
@ -152,10 +157,10 @@ func (list byMarketCapDesc) Less(i, j int) bool {
return m(list.sortable[j].MarketCap) < m(list.sortable[i].MarketCap) return m(list.sortable[j].MarketCap) < m(list.sortable[i].MarketCap)
} }
func (list byPreOpenDesc) Less(i, j int) bool { func (list byPreOpenDesc) Less(i, j int) bool {
return m(list.sortable[j].PreOpen) < m(list.sortable[i].PreOpen) return c(list.sortable[j].PreOpen) < c(list.sortable[i].PreOpen)
} }
func (list byAfterHoursDesc) Less(i, j int) bool { func (list byAfterHoursDesc) Less(i, j int) bool {
return m(list.sortable[j].AfterHours) < m(list.sortable[i].AfterHours) return c(list.sortable[j].AfterHours) < c(list.sortable[i].AfterHours)
} }
// Returns new Sorter struct. // Returns new Sorter struct.

Loading…
Cancel
Save