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

Error bitget when order with percetage of the wallet #14

Open
iZnogoude opened this issue Jun 10, 2024 · 36 comments
Open

Error bitget when order with percetage of the wallet #14

iZnogoude opened this issue Jun 10, 2024 · 36 comments

Comments

@iZnogoude
Copy link

I have a bot that place short order using a percentage of the walle. I have 200$ on the future account, and I use 100% of the wallet on this test and it returns in the log :

[2024/06/10][13:34:52]  ALERT: 2024-06-10 15:34:52 - BGUSER-1M3ZWDAW NOTUSDT sell 100% x1
[2024/06/10][13:34:52] ----------------------------
[2024/06/10][13:34:52]  * E: Invalid Order. Cancelling bitget {"code":"45110","msg":"less than the minimum amount 5 USDT","requestTime":1718026492923,"data":null}

Can you help me please?
Do you think it could be an error by my side?

Thanks a lot

@germangar
Copy link
Owner

It's probably an error in the balance value on my side. I just changed that code as part of the other fix. I'll check and fix it now.

@germangar
Copy link
Owner

Can you update and try again? I can't test this one myself. I don't have more than 10usdt in Bitget.

@iZnogoude
Copy link
Author

iZnogoude commented Jun 10, 2024

I just test and I have the same error.

FYI, i'm using CCXT 4.3.40

ubuntu@ip-172-31-16-xxx:~/whook$ git stash
Saved working directory and index state WIP on main: 662e4da Bitget (Fix): CCXT is now handling Bitget order parameters internally. If you update the script and Bitget doesn't work anymore make sure to update CCXT to the latest version.
ubuntu@ip-172-31-16-xxx:~/whook$ git pull
Updating 662e4da..383f327
Fast-forward
 main.py | 10 ----------
 1 file changed, 10 deletions(-)

@germangar
Copy link
Owner

I don't understand. As far as I can test with 10usdt seems to be working for me

I added a print to the code to check the balance conversion. Could you update and test it once more?

18:27:29 [bitget/bitget]  
18:27:29 [bitget/bitget]  ALERT: bitget NOTUSDT sell 100% x1
18:27:29 [bitget/bitget] ----------------------------       
   Balance: 10.01975372$ 100.0% = 10.01975372$
18:27:32 [bitget/bitget]  * Order successful: NOT/USDT:USDT sell 539.5 1x at price 0.018568 id 1184097873847549960
------------------------------
  1 positions found.
  NOT/USDT:USDT * isolated:1x * short * 530.0 * 9.8410[$] * -0.00[$] * -0.05%
------------------------------

@iZnogoude
Copy link
Author

I should be cursed.....

[2024/06/10][21:52:43] ALERT: 2024-06-10 21:52:43 - BGUSER-1M3ZWDAW NOTUSDT sell 10% x1
[2024/06/10][21:52:43] ----------------------------
[2024/06/10][21:52:43] Balance: 196.40890111$ 10.0% = 19.640890111$
[2024/06/10][21:52:44] * E: Invalid Order. Cancelling bitget {"code":"45110","msg":"less than the minimum amount 5 USDT","requestTime":1718049164084,"data":null}

@germangar
Copy link
Owner

Wait what. The conversion is correct. I'm so confused right now.

@iZnogoude
Copy link
Author

Me too....
I have a look on the bot, but it's working on bybit....

@germangar
Copy link
Owner

Don't worry. I keep trying to figure it out.

When you place orders in bitget with a value (not a percent) they do work, right? It only fails with the percent.

@iZnogoude
Copy link
Author

Absolutely, my bot that I use in tradingview order in values not in percent.

germangar added a commit that referenced this issue Jun 18, 2024
@germangar
Copy link
Owner

Give it another try with the latest update, please.

@iZnogoude
Copy link
Author

iZnogoude commented Jun 19, 2024 via email

@germangar
Copy link
Owner

germangar commented Jun 19, 2024

To configure a bunch of things without having to modify the script :)

The SHOW_* ones are to include those things when printing the positions.

The telegram stuff is a new feature to get notifications in telegram when an order fails. It's explained in the read.me now.

@iZnogoude
Copy link
Author

iZnogoude commented Jun 20, 2024 via email

@iZnogoude
Copy link
Author

iZnogoude commented Jun 22, 2024

I worked on a solution that use a value instead of a percentage of my wallet. I worked hard on that but I still have the issue....
The thing is that I use a bot on traddinview with the whook that works perfectly

With the delist bot :

19:12:13 [BGUSER-XXXX/bitget]  ALERT: 2024-06-21 19:12:13 - BGUSER-XXXX NOTUSDT sell 26.500679868 USDT x1
19:12:13 [BGUSER-XXXX/bitget] ----------------------------
19:12:16 [BGUSER-XXXX/bitget]  * E: Invalid Order. Cancelling bitget {"code":"45110","msg":"less than the minimum amount 5 USDT","requestTime":1718989936288,"data":null}

With TV bot :

[2024/06/22][04:00:06]  ALERT: BGUSER-XXXX ONDO/USDT:USDT sell 11.1@ x3
[2024/06/22][04:00:06] ----------------------------
[2024/06/22][04:00:07]  * Order successful: ONDO/USDT:USDT sell 11.1 3x at price 1.2102 id 1188228229530034176
[2024/06/22][08:00:04]  
[2024/06/22][08:00:04]  ALERT: BGUSER-1M3ZWDAW TON/USDT:USDT sell 1.5@ x3
[2024/06/22][08:00:04] ----------------------------
[2024/06/22][08:00:05]  * Order successful: TON/USDT:USDT sell 1.5 3x at price 7.162 id 1188288618884145159

There must be something wrong with the sell function I suppose.

@germangar
Copy link
Owner

BGUSER-XXXX NOTUSDT sell 26.500679868 USDT x1

You made a mistake in this alert. It's trying to sell 26,5 NOT, which is 0,371 USDT. For selling in usdt the amount has to look like this 26,5$
Can you try again?

@iZnogoude
Copy link
Author

Same :'(

14:56:17 [BGUSER-1M3ZWDAW/bitget] ALERT: 2024-06-22 14:56:17 - BGUSER-XXXXXX NOTUSDT sell 25$ x1
14:56:17 [BGUSER-1M3ZWDAW/bitget] ----------------------------
14:56:18 [BGUSER-1M3ZWDAW/bitget] * E: Invalid Order. Cancelling bitget {"code":"45110","msg":"less than the minimum amount 5 USDT","requestTime":1719060978643,"data":null}

@germangar
Copy link
Owner

Could you update whook and try once more with the same alert? I want to see how many NOTs is trying to sell

@iZnogoude
Copy link
Author

15:16:10 [BGUSER-1M3ZWDAW/bitget] ALERT: 2024-06-22 15:16:10 - BGUSER-XXXXX NOTUSDT sell 25$ x1
15:16:10 [BGUSER-1M3ZWDAW/bitget] ----------------------------
15:16:13 [BGUSER-1M3ZWDAW/bitget] * E: Order size invalid: 25.0 x1

@germangar
Copy link
Owner

Ok. That helps. For some reason it's not understanding the dollar sign and it thinks the order is in NOT. I'm now thinking this may be a text encoding issue. It's weird that it's printing the $ sign correctly, tho, but I think this may be it.

But you should be having the same problem in the other exchanges when you make this same order from your script.

@iZnogoude
Copy link
Author

iZnogoude commented Jun 22, 2024

Here the part of the code where is the $.
max_transfer_out is the amount of my wallet

short_amount = round((float(max_transfer_out) * percentage) / 100)
message = f'{datetime.now().strftime("%Y-%m-%d %H:%M:%S")} - {username} {highest_turnover_crypto} sell {short_amount}$ x{max_leverage}'

@germangar
Copy link
Owner

germangar commented Jun 22, 2024

Yeah, that's totally fine. If anything I suspect it may be something in the code that sends the webhook not setting the right text encoding. But this is a field I don't know much about, tbh. It should be set to UTF8, I guess.

@iZnogoude
Copy link
Author

iZnogoude commented Jun 22, 2024

In fact it's already implemented :

          if highest_turnover_crypto:
                with open(output_file, 'a', encoding='utf-8') as f:
                    f.write(f"{highest_turnover_crypto} - {valid_cryptos[highest_turnover_crypto]['info']}\n")
                print(f"Nouvelle crypto trouvée : {highest_turnover_crypto}")
                max_leverage = valid_cryptos[highest_turnover_crypto]['max_leverage']
                max_transfer_out = get_bitget_wallet_balance()
                if max_transfer_out is not None:
                    short_amount = round((float(max_transfer_out) * percentage) / 100)
                    message = f'{datetime.now().strftime("%Y-%m-%d %H:%M:%S")} - {username} {highest_turnover_crypto} sell {short_amount}$ x{max_leverage}'

@germangar
Copy link
Owner

Let's try this to see if the problem is really there.
I just added the commands 'force_usdt', 'force_percent' and 'force_basecurrency'.

Update and try sending your alert including the command 'force_usdt'. Let see if that makes it work before anything else.

@iZnogoude
Copy link
Author

Sorry, where I should add your command?
I'm not a pro like you ^_^'

@germangar
Copy link
Owner

Just add it to the alert at the end. It's just a replacement for the dollar sign

BGUSER-XXXXX NOTUSDT sell 25 x1 force_usdt

@iZnogoude
Copy link
Author

17:08:02 [BGUSER-1M3ZWDAW/bitget] ALERT: 2024-06-22 17:08:02 - BGUSER-XXXXXX NOTUSDT sell 25 x1 force_usdt
17:08:02 [BGUSER-1M3ZWDAW/bitget] ----------------------------
17:08:04 [BGUSER-1M3ZWDAW/bitget] * E: Order size invalid: 25.0 x1

@germangar
Copy link
Owner

germangar commented Jun 22, 2024

damn

You updated whook before sending it, right? I should have added a print ^_^'

@iZnogoude
Copy link
Author

Yes I did ^_^'

A friend who is working on a another bot also, have problems with values and percentages quantity also with the whook. He is using bybit and not bitget.
He has made a very simpliest script to buy and sell and it was working (without your whook)
So mayby there is a deepest issue somewere.
Did you think to split the whook to have one file by broker?

@germangar
Copy link
Owner

germangar commented Jun 22, 2024

I have plans to split it so you don't need to send the alerts with a webhook, but import whook into your script.

I don't understand how it is failing. It is receiving the correct number. 25 is there. It's just not converting it from usdt to NOT. But I don't understand why.

Could you enable 'verbose' in the config file and do it once more? Check if the print that says "CONVERTING" gives a result other than 25?

@iZnogoude
Copy link
Author

17:30:35 [BGUSER-1M3ZWDAW/bitget] ALERT: 2024-06-22 17:30:35 - BGUSER-XXXXX NOTUSDT sell 25 x1 force_usdt
17:30:35 [BGUSER-1M3ZWDAW/bitget] ----------------------------
CONVERTING (x1) 25.0 NOT ==> 25.0 contracts
17:30:38 [BGUSER-1M3ZWDAW/bitget] * E: Order size invalid: 25.0 x1

@germangar
Copy link
Owner

Ok, for some reason it's thinking it's not in USDT but in NOT. We are getting somewhere. I'm going to ask you for one more test. Hold on

@germangar
Copy link
Owner

Ok. Can you try one last time for today? Update and verbose on

@iZnogoude
Copy link
Author

iZnogoude commented Jun 22, 2024

Well done lad !!!!

17:52:38 [BGUSER-1M3ZWDAW/bitget]  ALERT: 2024-06-22 17:52:38 - BGUSER-1M3ZWDAW NOTUSDT sell 25 x1 force_usdt
17:52:38 [BGUSER-1M3ZWDAW/bitget] ----------------------------
PROCESSALERT: alert['isUSDT']: True isUSDT: True
PROCESSALERT: alert['isBaseCurrency']: False isBaseCurrency: False
PROCESSALERT: isUSDT path
   CONVERTING (x1) 25.0 USDT ==> 1676.2 contracts
17:52:41  * Activating Order NOT/USDT:USDT sell 1676.2 1x id 1188437752102428675

NOT/USDT:USDT * cross:1x * short * 1670.0 * 24.9080[$] * 0.01[$] * 0.05% * [ep]0.015 * [be]0.0149

Shall I keep force_usdt or shall I put the $?

@germangar
Copy link
Owner

germangar commented Jun 22, 2024

YAY!

I'm pretty sure if you issue the order with 25$ it will still fail. But at least it works now with 25 force_usdt. I'll leave dealing with the charset encoding for another day (mabye).

@germangar
Copy link
Owner

You should be able to use force_percent now too

@iZnogoude
Copy link
Author

I will try that and let you know.
Thanks a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants