Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Bittrex and Insufficient Funds (#708) #711

Merged
merged 1 commit into from
Nov 15, 2017
Merged

Conversation

KryptoNova
Copy link
Contributor

Added if statements so the exchange can have it's cut out of the purchase of the asset.
Most exchanges want their cut in BTC rather than the alt-coin being processed.
This modification allows for the exchange fee to be removed from the overall purchase price allowing for 100% of the currency balance to be spent without an insufficient funds error popping up.

Added if statements so the exchange can have it's cut out of the purchase of the asset.
Most exchanges want their cut in BTC rather than the alt-coin being processed.
This modification allows for the exchange fee to be removed from the overall purchase price allowing for 100% of the currency balance to be spent without an insufficient funds error popping up.
size = n(s.balance.currency).multiply(so.buy_pct).divide(100).multiply(s.exchange.makerFee / 100).format('0.00000000');
else
size = n(s.balance.currency).multiply(so.buy_pct).divide(100).multiply(s.exchange.takerFee / 100).format('0.00000000');
size = n(s.balance.currency - size).divide(price).format('0.00000000')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this overwrites the result of your if at :417

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct. I use "size" as a transitional holding variable in a live run of Zenbot. This is because there could be two different fees if the bot is running in maker or taker mode with the exchange.

The size variable that is calculated at :418 and :420 represents the amount of the exchange fee that is going to be taken if the purchase is completed after the buy_pct is calculated.

The final size variable at :421 represents the fee adjusted size of the amount of asset to purchase at the selected price.

This allows enough BTC to remain in the account to allow 100% buy of an asset without having a problem with insufficient funds. The side effect is that if you use a 50% buy_pct, it will not be the full 50% due to the fee coming out of the size. This is the formula, where fee represents maker or taker fee:

size = (balance * buy_pct - (balance * buy_pct * fee)) / price

Let me know if this needs more clarification or if there is a clearer way. This worked really well with the Bittrex exchange and eliminated the Insufficient Funds problems that I was running into.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I looked over - size there. Gotcha.

@DeviaVir DeviaVir merged commit b53abcc into DeviaVir:master Nov 15, 2017
@KryptoNova KryptoNova deleted the patch-2 branch November 18, 2017 01:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants