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.

KeyError: 'price' when calling calculate_fee with Gemini

See original GitHub issue
  • OS: macOS Mojave (version 10.14.5)
  • Programming Language version: Python 3.7.3
  • CCXT version: 1.18.758
  • Exchange: Gemini
  • Method: calculate_fee

I am trying to use calculate_fee method but getting KeyError: 'price' error. When I browse through the section Precision and limits in the manual it is not clear what I am doing wrong. Also, I can place the order itself on the exchange without any issues (last line that I have commented out).

symbol = 'ETH/USD' 
order_type = 'StopLimit'  
side = 'sell'   
amount = 1.0
price = 500.0 
exchange.load_markets()

# Error -->  KeyError: 'price' 
print(exchange.calculate_fee(symbol, order_type, side, amount, price))  

# Works fine without issues.
#order = exchange.create_order(symbol, order_type, side, amount, price)

Error:

File "/usr/local/lib/python3.7/site-packages/ccxt/base/exchange.py", line 1566, in calculate_fee
    cost = float(self.cost_to_precision(symbol, amount * price))
  File "/usr/local/lib/python3.7/site-packages/ccxt/base/exchange.py", line 1070, in cost_to_precision
    return self.decimal_to_precision(cost, ROUND, self.markets[symbol]['precision']['price'], self.precisionMode)
KeyError: 'price'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
razi-raiscommented, Jun 23, 2019

Working now. Thanks.

1reaction
razi-raiscommented, Jun 23, 2019

@kroitor After installing the build 1.18.791 getting error – NotSupported: gemini the Gemini API doc HTML markup has changed, breaking the parser of order limits and precision info for Gemini markets

File "/usr/local/lib/python3.7/site-packages/ccxt/gemini.py", line 178, in fetch_markets_from_web
 raise NotSupported(error)
ccxt.base.errors.NotSupported: gemini the Gemini API doc HTML markup has changed, breaking the parser of order limits and precision info for Gemini markets.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature engineering, key error in python? - Stack Overflow
Im running it in Jupyter notebook and it is executed in the given order. Same error occurs when I try to change dtype....
Read more >
How to Fix KeyError Exceptions in Python - Rollbar
The Python KeyError is an exception that occurs when an attempt is made to access an item in a dictionary that does not...
Read more >
Python KeyError Exceptions and How to Handle Them
In this tutorial, you'll learn how to handle Python KeyError exceptions. They are often caused by a bad key lookup in a dictionary,...
Read more >
How to fix Python KeyError Exceptions in simple steps?
The KeyError is raised when the item 'Eraser' is being accessed which is not present in prices. Whenever an exception is raised in...
Read more >
Python KeyError Exception Handling Examples - DigitalOcean
Python KeyError is raised when we try to access a key from dict, which doesn't exist. ... 1 Traceback (most recent call last):...
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