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

Fixed grid script - Client place order at wrong price when rebalance (during the longrun) #6523

Closed
mirono opened this issue Aug 16, 2023 · 11 comments
Labels

Comments

@mirono
Copy link

mirono commented Aug 16, 2023

Describe the bug

fixed_grid.py script issue.
script fail to place orders on initialize to rebalance.
Logs in attached screenshot.

Steps to reproduce

  1. start --script fixed_grid.py

Release version

dev-1.18.0

Type of installation

Docker

Attach required files

Monosnap Microsoft Teams Notification 2023-08-16 11-26-38
@mirono mirono added the bug label Aug 16, 2023
@nikspz nikspz changed the title SUMMARY OF BUG Fix grid script - failed to rebalance due to not enough balance Aug 16, 2023
@nikspz
Copy link
Contributor

nikspz commented Aug 16, 2023

hi @mirono Could you please provide log file and your script file used?

@mirono
Copy link
Author

mirono commented Aug 16, 2023

Here is the script and logs.
logs_fixed_grid.log
fixed_grid.py.zip

@nikspz nikspz changed the title Fix grid script - failed to rebalance due to not enough balance Fixed grid script - failed to rebalance due to not enough balance Aug 17, 2023
@nikspz
Copy link
Contributor

nikspz commented Aug 17, 2023

From what I see from the log that's price for SOL-USDT pair is wrong, also order amount that Client trying to submit are too low for binance exchange. Tried other pair (XRP-USDT, bot used correct price and order amount)

This one SOL-USDT, looks okay (can't reproduce your issue with wrong price/amount), I reduced order levels amount to 5
I guess you could try to reduce order levels and try to restart Client/ fix grid script

image
image

@mirono
Copy link
Author

mirono commented Aug 17, 2023

I made a manual trade to rebalance and be able to use the bot.
But the question is why it send wrong prices to Binance that are not in accordance to their precision, and als owhy the pair rate was wrong.
I guess if it can't be reproduced you can close it.

@nikspz nikspz closed this as completed Aug 18, 2023
@mirono
Copy link
Author

mirono commented Aug 18, 2023

Same thing happen today - the fixed grid need to sell some SOL but the order price is completely wrong (0.22 instead of 21.x).

@nikspz nikspz reopened this Aug 18, 2023
@nikspz
Copy link
Contributor

nikspz commented Aug 18, 2023

Okay, seems longrun needed to reproduce this one

for the info repeating initial screenshot here:
image

@nikspz nikspz changed the title Fixed grid script - failed to rebalance due to not enough balance Fixed grid script - Client place order at wrong price when rebalance (during the longrun) Aug 18, 2023
@rkc2000
Copy link
Contributor

rkc2000 commented Aug 18, 2023

How can I reproduce this? I tried running the same script pasted above but with binance_paper_trade and it appears to work as expected.
Screenshot 2023-08-18 at 14 31 29

@masimo12358
Copy link

masimo12358 commented Aug 18, 2023

In my specific case the grid run out of bounds in SOL-USDT on Binance as the price went below the low limit. As it bought SOL all the way down I was left with not enough USDT. I stopped it and exited Hummingbot. At some point later, I updated the limit and run it again. As there wasn't enough USDT it tried to rebalance by selling some SOL. It is at this point that the bug occurs - the price of SOL in the rebalance order is wrong.
Maybe try to reproduce by starting with a very low USDT balance?

@rkc2000
Copy link
Contributor

rkc2000 commented Aug 18, 2023

Got it, the bug is only in sell rebalance orders, not in buy. I've found the solution for it. In line 192, the correct code should be:

price = ref_price * (Decimal("100") + self.rebalance_order_spread) / Decimal("100")

I'll submit a pull request.

@rkc2000
Copy link
Contributor

rkc2000 commented Aug 18, 2023

Created pull request here:
#6527

@rapcmia
Copy link
Contributor

rapcmia commented Sep 7, 2023

Fixed on version 1.19.0

@rapcmia rapcmia closed this as completed Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants