Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bedbda8
commit 4ef4f7a
Showing
27 changed files
with
794 additions
and
750 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package cointop | ||
|
||
// Coin is the row structure | ||
type Coin struct { | ||
ID string | ||
Name string | ||
Slug string | ||
Symbol string | ||
Rank int | ||
Price float64 | ||
Volume24H float64 | ||
MarketCap float64 | ||
AvailableSupply float64 | ||
TotalSupply float64 | ||
PercentChange1H float64 | ||
PercentChange24H float64 | ||
PercentChange7D float64 | ||
LastUpdated string | ||
// for favorites | ||
Favorite bool | ||
// for portfolio | ||
Holdings float64 | ||
Balance float64 | ||
} | ||
|
||
func (ct *Cointop) allCoins() []*Coin { | ||
if ct.State.filterByFavorites { | ||
var list []*Coin | ||
for i := range ct.State.allCoins { | ||
coin := ct.State.allCoins[i] | ||
if coin.Favorite { | ||
list = append(list, coin) | ||
} | ||
} | ||
return list | ||
} | ||
|
||
if ct.State.portfolioVisible { | ||
var list []*Coin | ||
for i := range ct.State.allCoins { | ||
coin := ct.State.allCoins[i] | ||
if ct.PortfolioEntryExists(coin) { | ||
list = append(list, coin) | ||
} | ||
} | ||
return list | ||
} | ||
|
||
return ct.State.allCoins | ||
} | ||
|
||
func (ct *Cointop) coinBySymbol(symbol string) *Coin { | ||
for i := range ct.State.allCoins { | ||
coin := ct.State.allCoins[i] | ||
if coin.Symbol == symbol { | ||
return coin | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.