|
|
|
|
|
by dmos62
1857 days ago
|
|
Haha, variable for first candle is `fistCandle` [0]. Pretty mangled code. Weird to have to iterate over `avgPrice` to get pairs. This is calculating the average market change across all pairs for which `avgPrice` is tracked in this PaperWallet, whatever that means. type PaperWallet struct {
sync.Mutex
ctx context.Context
baseCoin string
counter int64
takerFee float64
makerFee float64
initialValue float64
feeder Feeder
orders []model.Order
assets map[string]*assetInfo
avgPrice map[string]float64
lastCandle map[string]model.Candle
fistCandle map[string]model.Candle
}
[...]
func (p *PaperWallet) Summary() {
var (
[...]
marketChange float64
)
[...]
for pair, price := range p.avgPrice {
[...]
marketChange += (p.lastCandle[pair].Close - p.fistCandle[pair].Close) / p.fistCandle[pair].Close
[...]
}
avgMarketChange := marketChange / float64(len(p.avgPrice))
[...]
}
[0] https://www.google.com/search?q=fist+candle&tbm=isch |
|