mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-06 15:10:59 +00:00
Offline worst case trade fees (#274)
* Really basic getSimulated fee function everywhere * Worst case fees for all exchanges * Adds tests, fixes comment spacing. Adds wrapper logic. Makes test api key var name consistent. Removes some okcoin ETT tests * Removes redundant functions * linting issues. Fixes introduces huobi issues * More linting * Stops trying to hide ETT problems, uses iota * Skips ETT tests for now
This commit is contained in:
@@ -428,6 +428,8 @@ func (i *ItBit) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) {
|
||||
fee = calculateTradingFee(feeBuilder.PurchasePrice, feeBuilder.Amount, feeBuilder.IsMaker)
|
||||
case exchange.InternationalBankWithdrawalFee:
|
||||
fee = getInternationalBankWithdrawalFee(feeBuilder.FiatCurrency, feeBuilder.BankTransactionType)
|
||||
case exchange.OfflineTradeFee:
|
||||
fee = getOfflineTradeFee(feeBuilder.PurchasePrice, feeBuilder.Amount)
|
||||
}
|
||||
|
||||
if fee < 0 {
|
||||
@@ -437,12 +439,17 @@ func (i *ItBit) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) {
|
||||
return fee, nil
|
||||
}
|
||||
|
||||
// getOfflineTradeFee calculates the worst case-scenario trading fee
|
||||
func getOfflineTradeFee(price, amount float64) float64 {
|
||||
return 0.0035 * price * amount
|
||||
}
|
||||
|
||||
func calculateTradingFee(purchasePrice, amount float64, isMaker bool) float64 {
|
||||
// TODO: Itbit has volume discounts, but not API endpoint to get the exact volume numbers
|
||||
// When support is added, this needs to be updated to calculate the accurate volume fee
|
||||
feePercent := 0.0025
|
||||
feePercent := 0.0035
|
||||
if isMaker {
|
||||
feePercent = 0
|
||||
feePercent = -0.0003
|
||||
}
|
||||
return feePercent * purchasePrice * amount
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user