whittlem / pycryptobot

Python Crypto Bot (PyCryptoBot)
Apache License 2.0
1.96k stars 739 forks source link

IndexError('index 0 is out of bounds for axis 0 with size 0') #793

Closed leohrs closed 1 year ago

leohrs commented 1 year ago

Trying to run in SHIBBRL market on binance, but I keep getting "IndexError('index 0 is out of bounds for axis 0 with size 0')" when the bot starts. happens both on Docker Desktop windows or directly on prompt. Version 8.0.5. Only tried binance so far. Also, I only get this message if running on an existing market in which I have sufficient funds and in live mode, meaning: • if I run in test mode it works. • If i choose another quote_currency, it'll prompt that I have insufficient funds. • If i try a non-existing market, it'll give me "non-existing market" message.

my config file:

"binance": { "api_url": "https://api.binance.com", "config": { "autorestart": 1, "base_currency": "SHIB", "disablebuynearhigh": 1, "enableinsufficientfundslogging": 1, "enabletelegrambotcontrol": 1, "granularity": "15m", "live": 1, "nobuynearhighpcnt": 1, "nosellmaxpcnt": 3, "nosellminpcnt": -13, "quote_currency": "BRL", "selllowerpcnt": -21, "telegram": 1, "trailingbuypcnt": 1, "trailingstoploss": -1, "trailingstoplosstrigger": 3, "disablelog": 0, "use_sell_fee": 1, "buypercent": 99, "termwidth": 180, "termcolor": 1, "verbose": 0, "log": 1, "debug": 1 }, "api_key_file": "binance.key" }, "telegram": { "token": "REMOVED", "user_id": "REMOVED", "client_id": "REMOVED", "datafolder": "", "logger_level": "DEBUG" }, "scanner" : { "atr72_pcnt" : 1.0, "exitaftersell" : 1, "enableleverage" : 0, "use_default_scanner" : 1, "maxbotcount" : 6, "exchange_bot_count": 3, "autoscandelay" : 0, "enable_buy_next": 1, "autostart": 0, "terminal_start_process": "" } }

thiazzz commented 1 year ago

I have the same. Did you already find a solution?

MirekF commented 1 year ago

Hi,same problem with BTC/BUSD Binance21. 4. 2023 v 14:33, thiazzz @.***>: I have the same. Did you already find a solution?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

leohrs commented 1 year ago

So far no solution, at least here. It seems that all config is fine, might be something with binance API handling maybe?

leohrs commented 1 year ago

update: same config works fine in kucoin

whittlem commented 1 year ago

I need to go through verification with Binance again. I stopped using Binance after it said I need to go through verification again. I need to sort this out to be able to troubleshoot this.

FenarkSEC commented 1 year ago

I am having the same issue as well, using the Helm chart on a Kubernetes cluster.

thiazzz commented 1 year ago

I could provide a temporary API key from a subaccount in Binance for testing? Would that make it easier to investigate and solve?

achillebnt commented 1 year ago

Maybe i found the problem: doing some debug i see in line 191 it try to set variable quote_min by index name MIN_NOTIONAL but dataframe doesn't have that index, instead it return this:

0 PRICE_FILTER 1 LOT_SIZE 2 ICEBERG_PARTS 3 MARKET_LOT_SIZE 4 TRAILING_DELTA 5 PERCENT_PRICE_BY_SIDE 6 NOTIONAL 7 MAX_NUM_ORDERS 8 MAX_NUM_ALGO_ORDERS

https://github.com/whittlem/pycryptobot/blob/bff0c3395276dd2e0ab62be0af2118c2d0adef59/models/AppState.py#L191

afgvdp commented 1 year ago

Same problem here. If it helps, the "opentrades" bot runs normally, but I am not able to start a bot manually or trough telegram.

I'll share the JSON from the "opentrades" bots, and the "scanner" bots.

This one WORKS:

{ "botcontrol": { "status": "active", "manualsell": false, "manualbuy": false, "started": "2023-04-23T16:36:32.134203", "startmethod": "telegram", "watchdog_ping": "2023-04-24T07:34:01.420447" }, "preventlosstriggered": false, "exchange": "binance", "margin": "-11.2487%", "delta": "-45.57", "price": 2.948, "df_high": " ", "from_df_high": " ", "trailingstoplosstriggered": false, "change_pcnt_high": 0.0, "indicators": { "EMA": true, "BULL": false, "MACD": true }, "signal": "WAIT" }

This one, DOESN'T work:

{ "botcontrol": { "status": "active", "manualsell": false, "manualbuy": false, "started": "2023-04-23T23:23:48.310596", "startmethod": "telegram" }, "preventlosstriggered": false, "exchange": "binance", "margin": "", "delta": "", "price": 0.0, "df_high": " ", "from_df_high": " ", "trailingstoplosstriggered": false, "change_pcnt_high": 0.0 }

whittlem commented 1 year ago

Maybe i found the problem: doing some debug i see in line 191 it try to set variable quote_min by index name MIN_NOTIONAL but dataframe doesn't have that index, instead it return this:

0 PRICE_FILTER 1 LOT_SIZE 2 ICEBERG_PARTS 3 MARKET_LOT_SIZE 4 TRAILING_DELTA 5 PERCENT_PRICE_BY_SIDE 6 NOTIONAL 7 MAX_NUM_ORDERS 8 MAX_NUM_ALGO_ORDERS

https://github.com/whittlem/pycryptobot/blob/bff0c3395276dd2e0ab62be0af2118c2d0adef59/models/AppState.py#L191

Thanks, I will take a look.

whittlem commented 1 year ago

Guys, can you confirm if this is a Telegram issue or a general issue? I used the config at the top and I don't get an error message when I run the bot on that market for live or test modes. If the issue happens just as the bot starts, I don't get it.

Config:

{
  "binance": {
    "api_url": "https://api.binance.com",
    "config": {
      "autorestart": 1,
      "base_currency": "SHIB",
      "disablebuynearhigh": 1,
      "enableinsufficientfundslogging": 1,
      "enabletelegrambotcontrol": 1,
      "granularity": "15m",
      "live": 0,
      "nobuynearhighpcnt": 1,
      "nosellmaxpcnt": 3,
      "nosellminpcnt": -13,
      "quote_currency": "BRL",
      "selllowerpcnt": -21,
      "telegram": 1,
      "trailingbuypcnt": 1,
      "trailingstoploss": -1,
      "trailingstoplosstrigger": 3,
      "disablelog": 0,
      "use_sell_fee": 1,
      "buypercent": 99,
      "termwidth": 180,
      "termcolor": 1,
      "verbose": 0,
      "log": 1,
      "debug": 0
    },
    "api_key_file": "binance.key"
  },
  "telegram": {
    "token": "<removed>",
    "client_id": "<removed>"
  }
}

Running bot like this: % python3 pycryptobot.py

whittlem commented 1 year ago

Maybe i found the problem: doing some debug i see in line 191 it try to set variable quote_min by index name MIN_NOTIONAL but dataframe doesn't have that index, instead it return this:

0 PRICE_FILTER 1 LOT_SIZE 2 ICEBERG_PARTS 3 MARKET_LOT_SIZE 4 TRAILING_DELTA 5 PERCENT_PRICE_BY_SIDE 6 NOTIONAL 7 MAX_NUM_ORDERS 8 MAX_NUM_ALGO_ORDERS

https://github.com/whittlem/pycryptobot/blob/bff0c3395276dd2e0ab62be0af2118c2d0adef59/models/AppState.py#L191

You are right about this... I was able to re-create this with a script.

import sys

sys.path.insert(0, ".")

from controllers.PyCryptoBot import PyCryptoBot  # noqa: E402
from models.TradingAccount import TradingAccount  # noqa: E402
from models.AppState import AppState  # noqa: E402
from models.exchange.binance import AuthAPI as BAuthAPI, PublicAPI as BPublicAPI  # noqa: E402

app = PyCryptoBot(exchange="binance")
account = TradingAccount(app)
state = AppState(app, account)
state.minimum_order_quote()

And returns this:

Traceback (most recent call last):
  File "<removed>/pycryptobot/examples/script-binance_v2.py", line 13, in <module>
    state.minimum_order_quote()
  File "<removed>/pycryptobot/./models/AppState.py", line 191, in minimum_order_quote
    df[df["filterType"] == "MIN_NOTIONAL"][["minNotional"]].values[0][0]
IndexError: index 0 is out of bounds for axis 0 with size 0

Although I'm not getting an error running the bot I can see the error above. I'll fix this and hopefully it fixed it for all of you. Thanks, this helped a lot.

MirekF commented 1 year ago

My configuration: (with live:0 it’s OK)

{ "binance": { "api_url": "https://api.binance.com", "api_key_file": "binance.key", "config" : { "base_currency" : "BTC", "quote_currency" : "BUSD", "live" : 1, "sellatloss" : 0, "sellatresistance" : 0, "trailingstoploss" : -1.5, "trailingstoplosstrigger" : 5, "nosellmaxpcnt" : 3, "nosellminpcnt" : -3, "disablebullonly" : 0, "disablebuynearhigh" : 1, "disablebuymacd" : 0, "disablebuyobv" : 1, "disablebuyelderray" : 0, "disablefailsafefibonaccilow" : 1, "disableprofitbankreversal" : 0, "disabletracker" : 1, "disabletelegram" : 1, "autorestart" : 1, "graphs" : 0, "stats" : 0, "enableinsufficientfundslogging": 1, "telegrambotcontrol": 0, "websocket": 0, "disablelog": 0, "buymaxsize": 0, "buyminsize": 0, "sellsmartswitch": 0, "trailingbuypcnt": 0.5, "telegramtradesonly": 0, "granularity": "1hour", "enableml": 0, "use_sell_fee": 1 } }, "telegram": { "token": "", "user_id": "0000000000", "client_id": "", "datafolder": "", "logger_level": "DEBUG" }, "scanner" : { "atr72_pcnt" : 1.0, "exitaftersell" : 1, "enableleverage" : 0, "use_default_scanner" : 1, "maxbotcount" : 6, "exchange_bot_count": 3, "autoscandelay" : 0, "enable_buy_next": 1, "autostart": 0, "terminal_start_process": "" } }

On 24. 4. 2023, at 20:31, Michael Whittle @.***> wrote:

Guys, can you confirm if this is a Telegram issue or a general issue? I used the config at the top and I don't get an error message when I run the bot on that market for live or test modes. If the issue happens just as the bot starts, I don't get it.

Config:

{ "binance": { "api_url": "https://api.binance.com", "config": { "autorestart": 1, "base_currency": "SHIB", "disablebuynearhigh": 1, "enableinsufficientfundslogging": 1, "enabletelegrambotcontrol": 1, "granularity": "15m", "live": 0, "nobuynearhighpcnt": 1, "nosellmaxpcnt": 3, "nosellminpcnt": -13, "quote_currency": "BRL", "selllowerpcnt": -21, "telegram": 1, "trailingbuypcnt": 1, "trailingstoploss": -1, "trailingstoplosstrigger": 3, "disablelog": 0, "use_sell_fee": 1, "buypercent": 99, "termwidth": 180, "termcolor": 1, "verbose": 0, "log": 1, "debug": 0 }, "api_key_file": "binance.key" }, "telegram": { "token": "", "client_id": "" } } Running bot like this: % python3 pycryptobot.py

— Reply to this email directly, view it on GitHub https://github.com/whittlem/pycryptobot/issues/793#issuecomment-1520640341, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA66ISATSFDWZWRWDDYVWLDXC3BHLANCNFSM6AAAAAAXGAHDEY. You are receiving this because you commented.

whittlem commented 1 year ago

I believe it's fixed. Doing a release now.

leohrs commented 1 year ago

With live 0 or open orders It Will run…

Le lun. 24 avr. 2023 à 15:47, MirekF @.***> a écrit :

My configuration: (with live:0 it’s OK)

{ "binance": { "api_url": "https://api.binance.com", "api_key_file": "binance.key", "config" : { "base_currency" : "BTC", "quote_currency" : "BUSD", "live" : 1, "sellatloss" : 0, "sellatresistance" : 0, "trailingstoploss" : -1.5, "trailingstoplosstrigger" : 5, "nosellmaxpcnt" : 3, "nosellminpcnt" : -3, "disablebullonly" : 0, "disablebuynearhigh" : 1, "disablebuymacd" : 0, "disablebuyobv" : 1, "disablebuyelderray" : 0, "disablefailsafefibonaccilow" : 1, "disableprofitbankreversal" : 0, "disabletracker" : 1, "disabletelegram" : 1, "autorestart" : 1, "graphs" : 0, "stats" : 0, "enableinsufficientfundslogging": 1, "telegrambotcontrol": 0, "websocket": 0, "disablelog": 0, "buymaxsize": 0, "buyminsize": 0, "sellsmartswitch": 0, "trailingbuypcnt": 0.5, "telegramtradesonly": 0, "granularity": "1hour", "enableml": 0, "use_sell_fee": 1 } }, "telegram": { "token": "", "user_id": "0000000000", "client_id": "", "datafolder": "", "logger_level": "DEBUG" }, "scanner" : { "atr72_pcnt" : 1.0, "exitaftersell" : 1, "enableleverage" : 0, "use_default_scanner" : 1, "maxbotcount" : 6, "exchange_bot_count": 3, "autoscandelay" : 0, "enable_buy_next": 1, "autostart": 0, "terminal_start_process": "" } }

On 24. 4. 2023, at 20:31, Michael Whittle @.***> wrote:

Guys, can you confirm if this is a Telegram issue or a general issue? I used the config at the top and I don't get an error message when I run the bot on that market for live or test modes. If the issue happens just as the bot starts, I don't get it.

Config:

{ "binance": { "api_url": "https://api.binance.com", "config": { "autorestart": 1, "base_currency": "SHIB", "disablebuynearhigh": 1, "enableinsufficientfundslogging": 1, "enabletelegrambotcontrol": 1, "granularity": "15m", "live": 0, "nobuynearhighpcnt": 1, "nosellmaxpcnt": 3, "nosellminpcnt": -13, "quote_currency": "BRL", "selllowerpcnt": -21, "telegram": 1, "trailingbuypcnt": 1, "trailingstoploss": -1, "trailingstoplosstrigger": 3, "disablelog": 0, "use_sell_fee": 1, "buypercent": 99, "termwidth": 180, "termcolor": 1, "verbose": 0, "log": 1, "debug": 0 }, "api_key_file": "binance.key" }, "telegram": { "token": "", "client_id": "" } } Running bot like this: % python3 pycryptobot.py

— Reply to this email directly, view it on GitHub < https://github.com/whittlem/pycryptobot/issues/793#issuecomment-1520640341>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA66ISATSFDWZWRWDDYVWLDXC3BHLANCNFSM6AAAAAAXGAHDEY . You are receiving this because you commented.

— Reply to this email directly, view it on GitHub https://github.com/whittlem/pycryptobot/issues/793#issuecomment-1520657243, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFUR2JN6NDML372QCI7BRTDXC3DCJANCNFSM6AAAAAAXGAHDEY . You are receiving this because you authored the thread.Message ID: @.***>

-- Leo Henry

whittlem commented 1 year ago

8.0.7 is available now. Docker image is building now. The issue should be fixed.

afgvdp commented 1 year ago

/addnew from telegram - WORKS /scanner and open bot - WORKS

Thank you!

afgvdp commented 1 year ago

Found a issue with the new release 8.0.7

The Index 0 is fixed, but now the Telegram Bot don't recognize the active bots. I think that maybe could be the same problem as this one:

https://github.com/whittlem/pycryptobot/discussions/727#discussioncomment-4632893

afgvdp commented 1 year ago

In 8.0.7 BOTs are not buying due to "Insufficient Funds":

Bot1 2023-04-25 02:15:00 POLYXUSDT 15m Skipping LIVE Buy Order -- Insufficient Funds

Manual Buy doesn't work either.

demkoma20 commented 1 year ago

I am still getting indexError when I stopped previous session and set LIMIT sell order. On lower price levels I tried to start but got IndexError. When I unlock funds from LIMIT order bot works but start where ends. And that's what I don't want.

whittlem commented 1 year ago

In 8.0.7 BOTs are not buying due to "Insufficient Funds":

Bot1 2023-04-25 02:15:00 POLYXUSDT 15m Skipping LIVE Buy Order -- Insufficient Funds

Manual Buy doesn't work either.

This may sound like a thick question, but I have to ask. You definitely have sufficient funds? E.g., at least 10 of the quote currently (as a guide)

whittlem commented 1 year ago

This week is super busy for me but I'll take a look next week. If anyone can help narrow down the problem, that would help. For example, is it Binance only? Is it Docker or CLI or both? Is it happening with the Telegram bot only or both?, If you can provide more info to help me recreate what you are seeing that would help. If you can provide your config.json and the way you are running your bots that would help as well.

afgvdp commented 1 year ago

In 8.0.7 BOTs are not buying due to "Insufficient Funds": Bot1 2023-04-25 02:15:00 POLYXUSDT 15m Skipping LIVE Buy Order -- Insufficient Funds Manual Buy doesn't work either.

This may sound like a thick question, but I have to ask. You definitely have sufficient funds? E.g., at least 10 of the quote currently (as a guide)

Hi Michael, it was solved in the Chat. Another guy told me to ser "buymaxsize". I did it and problem solved!

demkoma20 commented 1 year ago

This week is super busy for me but I'll take a look next week. If anyone can help narrow down the problem, that would help. For example, is it Binance only? Is it Docker or CLI or both? Is it happening with the Telegram bot only or both?, If you can provide more info to help me recreate what you are seeing that would help. If you can provide your config.json and the way you are running your bots that would help as well.

I tried only on Binance. Without Telegram or Docker/Kubernetes, running in shell through python3 ./pycryptobot.py --logfile cryptobot-BTCUSDT.log --market BTCUSDT --granularity 3600 Issue is occured when:

  1. 1st bot run - success
  2. Stop bot
  3. Previously bought funds by bot are locked in LIMIT order
  4. 2nd bot run - fail
  5. Unlock funds
  6. Bot run - success and started where ends
whittlem commented 1 year ago

I'm getting same " Skipping LIVE Buy Order -- Insufficient Funds " message. There is definitely a bug. I'm troubleshooting it and just waiting for the next buy signal to see what happens.

whittlem commented 1 year ago

Fixed for me in 8.0.9. Give it a try and let me know.