mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-04 15:10:54 +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:
@@ -680,6 +680,8 @@ func (o *OKGroup) GetFee(feeBuilder *exchange.FeeBuilder) (fee float64, _ error)
|
||||
break
|
||||
}
|
||||
}
|
||||
case exchange.OfflineTradeFee:
|
||||
fee = getOfflineTradeFee(feeBuilder.PurchasePrice, feeBuilder.Amount)
|
||||
}
|
||||
if fee < 0 {
|
||||
fee = 0
|
||||
@@ -688,10 +690,15 @@ func (o *OKGroup) GetFee(feeBuilder *exchange.FeeBuilder) (fee float64, _ error)
|
||||
return fee, nil
|
||||
}
|
||||
|
||||
// getOfflineTradeFee calculates the worst case-scenario trading fee
|
||||
func getOfflineTradeFee(price, amount float64) float64 {
|
||||
return 0.0015 * price * amount
|
||||
}
|
||||
|
||||
func calculateTradingFee(purchasePrice, amount float64, isMaker bool) (fee float64) {
|
||||
// TODO volume based fees
|
||||
if isMaker {
|
||||
fee = 0.001
|
||||
fee = 0.0005
|
||||
} else {
|
||||
fee = 0.0015
|
||||
}
|
||||
|
||||
@@ -414,6 +414,10 @@ func (o *OKGroup) GetWebsocket() (*exchange.Websocket, error) {
|
||||
|
||||
// GetFeeByType returns an estimate of fee based on type of transaction
|
||||
func (o *OKGroup) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error) {
|
||||
if (o.APIKey == "" || o.APISecret == "") && // Todo check connection status
|
||||
feeBuilder.FeeType == exchange.CryptocurrencyTradeFee {
|
||||
feeBuilder.FeeType = exchange.OfflineTradeFee
|
||||
}
|
||||
return o.GetFee(feeBuilder)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user