java-binance-api
java-binance-api copied to clipboard
How to place an order to buy AND sell
In your code example you explain how to trade BTC with ETH, but how to trade ETH with BTC?
Maybe in this line
BinanceOrderPlacement placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.BUY);
to switch you can use
BinanceOrderPlacement placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.SELL);
?
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