mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Added various calculation functions.
This commit is contained in:
16
common.go
16
common.go
@@ -8,6 +8,22 @@ import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
func CalculateAmountWithFee(amount, fee float64) (float64) {
|
||||
return amount + CalculateFee(amount, fee)
|
||||
}
|
||||
|
||||
func CalculateFee(amount, fee float64) (float64) {
|
||||
return amount * (fee / 100)
|
||||
}
|
||||
|
||||
func CalculatePercentageDifference(amount, secondAmount float64) (float64) {
|
||||
return (secondAmount - amount) / amount * 100
|
||||
}
|
||||
|
||||
func CalculateNetProfit(amount, priceThen, priceNow, costs float64) (float64) {
|
||||
return (priceNow * amount) - (priceThen * amount) - costs
|
||||
}
|
||||
|
||||
func SendHTTPRequest(url string, jsonDecode bool, result interface{}) (err error) {
|
||||
res, err := http.Get(url)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user