How to create a limit buy order using the full available amount on the right-hand side of the pair?
See original GitHub issueConsidering that we are using Binance, and we would like to trade over the pair ETH/BTC, for example.
What would it be the best way to create a limit buy order using the full available amount on the right-hand side of the pair?
For example, let’s consider, for explaining purposes, that the price of the pair ETH/BTC is like 10 ETH -> 1 BTC
,
and we have a total amount of 20 BTC
in our balance.
If we were using the Binance UI, we could create a limit buy order (buying ETH) using 100% of our BTC balance (in this case 20 BTC), and we could stipulate the price of 10 ETH for 1 BTC. So when this order is fulfilled, we would get 200 ETH in our balance. How can we do that with CCXT?
Please note, that if this was the inverse, selling ETH, would be easier, since we could get the current ETH balance and sell it all for the stipulated price, with a code like this one (python):
eth_balance = ccxt_exchange_instance.fetchBalance()['free']['ETH']
ccxt_exchange_instance.create_order(
'ETH/BTC',
'limit',
'sell',
eth_balance,
10, # 10 ETH -> 1 BTC
{}
)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Use a market order and
quoteOrderQty
in params to specify amount in the quote currency (BTC) on BinanceA limit order requires the amount and the price, where:
Therefore when both multipliers are known, you can use pure logic + arithmetics to calculate the values of your limit order.