webcerebrium / java-binance-api

Java Binance API Client
MIT License
73 stars 40 forks source link

How to place an order to buy AND sell #6

Open spapapan opened 6 years ago

spapapan commented 6 years ago

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

spapapan commented 6 years ago

Maybe in this line

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

to switch you can use

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

?

wcrbrm commented 6 years ago

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