java-binance-api icon indicating copy to clipboard operation
java-binance-api copied to clipboard

How to place an order to buy AND sell

Open spapapan opened this issue 7 years ago • 2 comments

In your code example you explain how to trade BTC with ETH, but how to trade ETH with BTC?

spapapan avatar Jan 06 '18 10:01 spapapan

Maybe in this line

BinanceOrderPlacement placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.BUY);

to switch you can use

BinanceOrderPlacement placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.SELL);

?

spapapan avatar Jan 06 '18 11:01 spapapan

hi @spapapan Whether you are buying or you are selling - it depends on the market symbol. on a market there is usually a base asset and there is asset that you are trading against.

When you are looking at ETHBTC market symbol, that means ETH would be bought. and ETH would be sold - and the last part of the symbol is the base asset.

so, if you want to buy ETH for BTC, you are doing

new BinanceOrderPlacement(new BinanceSymbol("ETHBTC"), BinanceOrderSide.BUY);

and if you want to sell ETH for BTC, you are doing

new BinanceOrderPlacement(new BinanceSymbol("ETHBTC"), BinanceOrderSide.SELL);

Hope that makes it a bit more clear for you

wcrbrm avatar Jan 06 '18 12:01 wcrbrm