Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Galaxyscore.py with paperaccount - error: Fetching 3Commas account failed #49

Closed
mthad opened this issue Dec 20, 2021 · 13 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@mthad
Copy link

mthad commented Dec 20, 2021

Describe the bug
Hello,
First of all thank you for sharing this amazing tools!

I tried to use galaxyscore.py using docker with paper account on 3 commas.
When I start the container, I get this error message:

2021-12-20 11:03:28 - galaxyscore.py - 3Commas bot helper galaxyscore!

2021-12-20 11:03:28 - galaxyscore.py - Started at Monday 11:03:28 20-12-2021

2021-12-20 11:03:28 - galaxyscore.py - Loaded configuration from 'config/galaxyscore.ini'

2021-12-20 11:03:28 - galaxyscore.py - Notifications are enabled

2021-12-20 11:03:28 - galaxyscore.py - Reloaded configuration from 'config/galaxyscore.ini'

2021-12-20 11:03:28 - galaxyscore.py - Fetched 3Commas pairs blacklist OK (0 pairs)

2021-12-20 11:03:28 - galaxyscore.py - Fetched 3Commas BTC price OK (45938.02 USDT)

2021-12-20 11:03:29 - galaxyscore.py - Fetched LunarCrush ranking OK (100 coins)

2021-12-20 11:03:29 - galaxyscore.py - Bot base currency: USDT

2021-12-20 11:03:29 - galaxyscore.py - Bot minimal 24h BTC volume: 0.0

Traceback (most recent call last):

  File "galaxyscore.py", line 651, in <module>

    find_pairs(botdata)

  File "galaxyscore.py", line 430, in find_pairs

    marketcode = get_threecommas_account(thebot["account_id"])

  File "galaxyscore.py", line 309, in get_threecommas_account

    logger.error("Fetching 3Commas account failed with error: %s" % error["msg"])

KeyError: 'msg'

Environment:

  • Python version: v 3.9.9
  • Operating System: Windows 10 + Docker Destop v4.3.0

Additional context
I am using paper account on 3 commas

Thanks for your help

@mthad mthad added the bug Something isn't working label Dec 20, 2021
@mthad
Copy link
Author

mthad commented Dec 20, 2021

tried with release 0.7.9 it worked. but not with main branch. I close this issue

@mthad mthad closed this as completed Dec 20, 2021
@cyberjunky
Copy link
Owner

Why close an issue which isn't fixed?

I think you need to read the documentation and add AccountRead rights to your 3Commas API key

@cyberjunky cyberjunky reopened this Dec 20, 2021
@mthad
Copy link
Author

mthad commented Dec 21, 2021

Hi,
sorry for closing it too early, mistake on my side.
Regarding your suggestion, I already set 3Commas API Key with this parameter.
my API key - BotsRead, BotsWrite, AccoundsRead:
image

@cyberjunky
Copy link
Owner

Ok will check, thanks

@mthad
Copy link
Author

mthad commented Dec 21, 2021

Hi,
in the function named def get_threecommas_account(accountid):

this piece of code seems to cause the issue (line 299):
additional_headers={"Forced-Mode": "real"}

I commented it and it worked

Did a quick check and it's also present in the code of the following scripts:

  • galaxyscore.py
  • altrank.py
  • compound.py
  • coinmarketcap.py
  • watchlist.py
  • watchlist_100eye.py

Repoduced the issue on galaxyscore.py, altrank.py, compound.py, coinmarketcap.py
After commenting the concerned line it worked.
Did not test with watchlist.py, watchlist_100eye.py

@cyberjunky
Copy link
Owner

But without it real mode doesn't work correctly when you put the webinterface in paper mode I think (it was an issue a while ago)
Can you test this?
If this is the case we need to reinstate the old accountmode setting and use that, but it means we cannot run mixed bots (paper/real)

@cyberjunky
Copy link
Owner

Maybe they (3Commas) changed this behavior to work with all modes now, since it was strange behavior anyway.

@mthad
Copy link
Author

mthad commented Dec 22, 2021

Hi,

Scenario tested with galaxyscore.py (commented the line additional_headers={"Forced-Mode": "real"}):

  1. switched on paper account on web interface, launched galaxyscore.py with botids of real account in galaxyscore.ini
    --> Result: Bot id in real account successfully updated with the right pairs.
  2. switched on real account on webinterface, launched galaxyscore.py with botids of paper account in galaxyscore.ini
    --> Result: Bot id in paper account successfully updated with the right pairs.

From the official documentation of 3commas API:
" By default, API mode(real or paper) synchronized with mode in web/app.
You can set a forced mode for public API through the request header "Forced-Mode" with values "real" or "paper".
"

(speculation) It's probably true and matters for other actions through this api, but in our case, because we specify botids, it looks like it doesn't matter to be in real or paper account in webinterface. Ids are unique

@cyberjunky
Copy link
Owner

@mthad I know about that text.
But the issue is to determine the correct mode I have to get the market_code of an account_id linked to a botid.
And if this request also needs the correct mode for that account (which it the case, it turns out) We have a chicken and egg problem.
I cannot rely on the account_name in the bot for this, this can be "Paper account 12345" or "Test account" or something else.

To recap:
I use the get_threecommas_account(accountid) code to get the market_code which tells me which market the bot is connected too, 'binance' for binance and 'paper_trading' if link to paper account.

I would expect I can read both ids (from paper and real botid) with mode is 'real' but this fails sometime as you pointed out, and without it the reading of the 'real' account fails if web interface is in paper mode.

There is other code, but this switched the mode (not only for a webcall) this is also unwanted...

@cyberjunky
Copy link
Owner

@mthad Working solution it seems: I first read account data in paper mode, if this doesn't give me the market_code for theaccount_id I read it again using real mode ;-)

@cyberjunky
Copy link
Owner

@mthad can you test with latest version?

@mthad
Copy link
Author

mthad commented Dec 31, 2021

Hi,
@cyberjunky, tested with new version (main branch), worked successfully in scenario below.
Scenario tested with galaxyscore.py:

  1. switched on paper account on web interface, launched galaxyscore.py with botids of real account in galaxyscore.ini
    --> Result: Bot id in real account successfully updated with the right pairs.

  2. switched on real account on webinterface, launched galaxyscore.py with botids of paper account in galaxyscore.ini
    --> Result: Bot id in paper account successfully updated with the right pairs.

Thanks for the fix ;-).
Happy new year :-)!

@cyberjunky
Copy link
Owner

@mthad Thank you for reporting and testing, have a happy new year too! 🍾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants