question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cryptopia create_limit_buy_order failing with an exception

See original GitHub issue

When using the Python version of the library, create_limit_buy_order() fails with the following exception:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.2\helpers\pydev\_pydevd_bundle\pydevd_exec2.py", line 3, in Exec
    exec(exp, global_vars, local_vars)
  File "<input>", line 1, in <module>
  File "D:\Development\crypto-p1\venv\lib\site-packages\ccxt\base\exchange.py", line 1009, in create_limit_buy_order
    return self.create_order(symbol, 'limit', 'buy', *args)
  File "D:\Development\crypto-p1\venv\lib\site-packages\ccxt\cryptopia.py", line 354, in create_order
    'Amount': self.amount_to_precision(symbol, amount),
  File "D:\Development\crypto-p1\venv\lib\site-packages\ccxt\base\exchange.py", line 780, in amount_to_precision
    return self.truncate(amount, self.markets[symbol]['precision']['amount'])
  File "D:\Development\crypto-p1\venv\lib\site-packages\ccxt\base\exchange.py", line 436, in truncate
    return '{0:f}'.format(Decimal(num).quantize(math.pow(10, -precision)))
TypeError: conversion from float to Decimal is not supported

The issue is that the precision argument in Decimal.quantize(precision) should be of Decimal type rather than a float.

I’m not sure if this issue affects other exchanges, seeing that it is present in exchange.py.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
maltiumcommented, Jan 4, 2018

I confirm that it works.

Thank you for the prompt fix.

1reaction
maltiumcommented, Jan 4, 2018

Please note that commit 4aa1980 does not fix this issue. The cryptopia exchange uses the truncate(num, precision=0) method rather than truncate_to_string(num, precision=0).

Read more comments on GitHub >

github_iconTop Results From Across the Web

ccxt Documentation - Read the Docs
ccxt library you may get a warning or an exception, saying No 'Access-Control-Allow-Origin' header is present on the requested resource.
Read more >
Cryptopia Limited | Grant Thornton New Zealand
For information on the status of this liquidation, please refer to the information issued by the Liquidators.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found