<p>You are submitting a float value. Float values are not totaly accurate:</p>

<pre><code>&gt;&gt;&gt; 0.9 
0.90000000000000002
</code></pre>

<p>Thats why the <a href="https://www.bitfinex.com/pages/api" rel="nofollow">specification</a> requires a <a href="https://docs.python.org/2/library/decimal.html" rel="nofollow">Decimal datatype</a>:</p>

<pre><code>&gt;&gt;&gt; from decimal import Decimal
&gt;&gt;&gt; Decimal("0.001") 
</code></pre>

CC BY-SA 3.0
2014-06-28T20:03:38.453Z
2014-06-28T20:03:38.453Z
Dennis Kriechel
<p>I started writing code for the Bitfinex api yesterday and I've been struggling quite a lot with this.
I am using jndok's <a href="http://jndok.net/bitfinexapi.html" rel="nofollow">python implementation</a>. </p>

<p>I added my pyblic and secret keys and wrote this line of code at the end with python 2.7 on Windows 8:</p>

<pre><code>rep = place_order(0.001, 589.0, 'sell', 'limit', exchange='bitfinex')
</code></pre>

<p>And I thought that would do it but the reply I get 'Key amount should be a decimal string' and the order is not placed.
I also tried to print the reply code I get from the server and it is 400.</p>

<p>How can this be resolved?</p>

<api><exchange-order><bitfinex><python>
API Bitfinex question: "key amount should be a decimal string"?
Erik Sillén
# API Bitfinex question: "key amount should be a decimal string"?

(Asked by: username_0 on 2014-06-28)

I started writing code for the Bitfinex api yesterday and I've been struggling quite a lot with this.
I am using jndok's [python implementation](http://jndok.net/bitfinexapi.html).

I added my pyblic and secret keys and wrote this line of code at the end with python 2.7 on Windows 8:

```
rep = place_order(0.001, 589.0, 'sell', 'limit', exchange='bitfinex')

```

And I thought that would do it but the reply I get 'Key amount should be a decimal string' and the order is not placed.
I also tried to print the reply code I get from the server and it is 400.

How can this be resolved?

**Tags:** api, exchange-order, bitfinex, python


---

## 1 answers

### Answer by username_1 on 2014-06-28. Score: 3

You are submitting a float value. Float values are not totaly accurate:

```
>>> 0.9 
0.90000000000000002

```

Thats why the [specification](https://www.bitfinex.com/pages/api) requires a [Decimal datatype](https://docs.python.org/2/library/decimal.html):

```
>>> from decimal import Decimal
>>> Decimal("0.001") 

```


---

