When step size is available then adjust total amount (with fee included) by the step size using TradingService#roundByStep #309

Merged
dazito merged 6 commits from adjust-fee-by-step-size into master 2021-01-22 13:04:47 -08:00
dazito commented 2021-01-07 15:27:34 -08:00 (Migrated from github.com)

Currently, exchanges with FeeComputation set to CLIENT do not perform the roundByStep() adjustment which my lead to org.knowm.xchange.exceptions.OrderNotValidException: Filter failure: LOT_SIZE (HTTP status code: 400) when performing a trade.

In this pull we call roundByStep using CurrencyPairMetaData#getAmountStepSize().

Do not merge this PR just yet. I will run this code changes for a while to see if it really fixed the OrderNotValidException

Currently, exchanges with `FeeComputation` set to `CLIENT` do not perform the `roundByStep()` adjustment which my lead to `org.knowm.xchange.exceptions.OrderNotValidException: Filter failure: LOT_SIZE (HTTP status code: 400)` when performing a trade. In this pull we call `roundByStep` using `CurrencyPairMetaData#getAmountStepSize()`. Do not merge this PR just yet. I will run this code changes for a while to see if it really fixed the `OrderNotValidException`
scionaltera (Migrated from github.com) reviewed 2021-01-19 09:39:51 -08:00
@ -470,9 +470,9 @@ public class TradingService {
.multiply(exchangeService.getExchangeFee(exchange, currencyPair, true))
.setScale(BTC_SCALE, RoundingMode.HALF_EVEN);
scionaltera (Migrated from github.com) commented 2021-01-19 09:39:51 -08:00

This doesn't seem right to do roundByStep() inside addFees(). We do it once in getVolumeForEntryPosition() and then possibly addFees() changes the value. I think instead we should move the roundByStep() out into entryPosition() after addFees() so that we do the rounding as the last step, in one place, right before submitting the orders. Same idea for exiting the positions.

This doesn't seem right to do `roundByStep()` inside `addFees()`. We do it once in `getVolumeForEntryPosition()` and then possibly `addFees()` changes the value. I think instead we should move the `roundByStep()` out into `entryPosition()` after `addFees()` so that we do the rounding as the last step, in one place, right before submitting the orders. Same idea for exiting the positions.
dazito (Migrated from github.com) reviewed 2021-01-19 14:13:51 -08:00
@ -470,9 +470,9 @@ public class TradingService {
.multiply(exchangeService.getExchangeFee(exchange, currencyPair, true))
.setScale(BTC_SCALE, RoundingMode.HALF_EVEN);
dazito (Migrated from github.com) commented 2021-01-19 14:13:51 -08:00

Yeah, good point. I will commit the changes in a moment

Yeah, good point. I will commit the changes in a moment
dazito commented 2021-01-22 12:54:58 -08:00 (Migrated from github.com)

Ready to merge, I have ran it for a few days. No major issues.

Ready to merge, I have ran it for a few days. No major issues.
Commenting is not possible because the repository is archived.
No description provided.