webcerebrium / java-binance-api

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

market buy price necessary?[question] #14

Open pimp22 opened 6 years ago

pimp22 commented 6 years ago

I am looking at the market buy method. If I use type = market, is it necessary to set both price and quantity? I mean like when we use the binance pc client, we have the option to press 25,50% etc and just click buy, and it will give is the markets current best price, without having to thinking about what the price is (i just notice the rise). Can you follow me, or is it too unclear? All the code for limit/market buy is the same, only the type differ, but maybe i misunderstood their works.

Basically, can I make the the buy say 50% of my funds, without pinging the price first. Thanks

wcrbrm commented 6 years ago

@pimp22 no, there is no percentage support (you should calculate in on upper level) Quantity must be specified with exact numbers of asset that needs to be bought/sold.

Price, at the same time, should not be specified at all for a market order Please also make sure you are using 1.0.8 version.

pimp22 commented 6 years ago

so to mimic the "market buY" function in the pc client, i must ping the coin frequently to know what the price is, so i can calculate how much of that coin (asset?) i want to buy for my btc

pimp22 commented 6 years ago

doesnt seem the lot size thing work intended for all coins. i get "no value" on some of the coins (i spelled them right , e.g. IOTA )

wcrbrm commented 6 years ago

so to mimic the "market buY" function in the pc client, i must ping the coin frequently to know what the price is, so i can calculate how much of that coin (asset?) i want to buy for my btc

The task of making market buy orderS is much complex then it is described. You much analyze order book properly for that and hoping that you are fast enough to submit your order before anything will change in the order book. In addition, exchange might have their own addition to this market buy algorithm.

doesnt seem the lot size thing work intended for all coins. i get "no value" on some of the coins (i spelled them right , e.g. IOTA )

Please create separate ticket with full code example. I cannot really help having so little information

pimp22 commented 6 years ago

Correct me if im wrong, im pretty sure if you make a market buy at market price (as figures in pc client) for 75%, it simply takes (fund0.75/current coin price) and then buys the "best market price", trying to buy "fund0.75/current coin price".

pimp22 commented 6 years ago

BinanceExchangeSymbol BN = symbols.stream().filter(a -> a.getQuoteAsset().equals(s)).findFirst().get(); System.out.println("coin Lot Size: {}"+ BN.getSymbol().toString());

I just used this new example and use a string s to pass in name. Its capital lettered. I also printed out the list of symbols. "IOTA" is in there, so im not sure why I get the no value error when s = "IOTA." I merely tried different abbr. for coins as s, but some fail with the described error.

Basically I was trying to grab the info (ik it not getSymbol... that wa just some testing) for how many decimals a coin accepts. But maybe Im better off just writing them down, if Im getting errors with this?

Thanks for helping