I get the following message when trying to send a buy/sell order through btc-e api using a variable: "you incorrectly entered one of the fields".

This is the line of code I use for sending an order:

APIMain.Trade(BtcePair.BtcUsd, TradeType.Sell, Math.Round(myAskP, 4), Math.Round(myAskQ, 4));

Sending an order via api does work when I enter it like this:

APIMain.Trade(BtcePair.BtcUsd, TradeType.Sell, 800m, 0.5m);

How do I force a decimal variable to be formatted like the line above? Anybody experienced similar problems?

  • might be helpful if you could mention the particular programming language you are using I'm guessing maybe Java?
    – Mark S.
    Dec 14, 2013 at 4:03

2 Answers 2


The exact problem you're facing regards the number of acceptable decimal digits in the rate field.

You're trying to submit an order on the BTC/USD pair, which happens to have a max decimal allotment of 3. Meaning, you can submit an order for example 800.123, but NOT 800.1234 Not all pairs are the same. LTC/USD can have 6 digits, most BTC based pairs can accept 5 digits.

To get a list of exact information regarding the individual pairs, use this public endpoint for a JSON object that gives you all the values: https://btc-e.com/api/3/info

As far as I know, all pairs' amount fields can have a max of 8 decimals. You are rounding both the amount and rate to 4 digits. Fix the rate field and it should work.

Please keep in mind when I say "decimal places" I mean actual number of digits after the period in a number. Not the numerical type decimal that you are using. Using a double or float will work as well, provided they are rounded properly.


The problem seems to be in the Price. This worked:

APIMain.Trade(BtcePair.BtcUsd, TradeType.Buy, decimal.Floor(myBidP),decimal.Round(myBidQ,4));

Can somebody confirm that the price must be rounded to the nearest integer?

Bonne chance trading everybody......

  • Price and quantity are automatically rounded by BTC-e. I believe they round to the nearest number (e.g. 0.5 up 0.4999 down), still I would strongly recommend rounding down yourself to avoid missing trades due to insufficient funds.
    – Mark
    Jan 31, 2014 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.