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.

List index out of range for orders[coin]

See original GitHub issue

When update_portfolio is called, I very often get a list index out of range error and the program crashes.

  File "app.py", line 286, in <module>
    update_porfolio(orders, last_price, volume)
  File "app.py", line 228, in update_porfolio
    'symbol': orders[coin][0]['symbol'],
IndexError: list index out of range

Using my debugger, it looks like some currencies that the bot tries to buy are in the orders dict, but some don’t end up going in there and are just empty.

image

I’m guessing it’s an issue where the client is retrieving orders too quickly before they place on Binance’s end?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
atmarcommented, May 9, 2021

I have the same issue all the time in live aswell. Tried changing all requests to await using async functions from binance library, but same result. It’s a big problem because it creates the orders, crashes before it puts it in the JSON and the orders are stuck in limbo until you manually sell them back to USDT on binance

1reaction
andrewsauter-nbcunicommented, May 9, 2021

Not the original coder and I’m not familiar with Python, but in NodeJs there’s this concept of async/await for things like this. I did a quick google and I think this might be similar: https://docs.python.org/3/library/asyncio-task.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

List Index Out of Range – Python Error Message Solved
In this article you'll see a few of the reasons that cause the list index out of range Python error. Besides knowing why...
Read more >
How to fix - List Index Out of Range in Python - GeeksforGeeks
In this article, we are going to see how to fix – List Index Out of Range in Python. Why we get- List...
Read more >
Can anyone help me to understand why i have the error "list ...
Can anyone help me to understand why i have the error "list index out of range"? · i goes past the end of...
Read more >
How to Fix IndexError in Python - Rollbar
The IndexError in Python occurs when an item from a list is attempted to be accessed that is outside the index range of...
Read more >
IndexError: list index out of range - YouTube
Traceback (most recent call last): File "stdin", line 1, in moduleIndexError: list index out of rangelike this video, share, ...
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 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