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

Wrong quantity #22

Open
Th0rgal opened this issue Jul 22, 2021 · 5 comments
Open

Wrong quantity #22

Th0rgal opened this issue Jul 22, 2021 · 5 comments

Comments

@Th0rgal
Copy link
Owner

Th0rgal commented Jul 22, 2021

Hello @Ma007ks,

I have an issue with your commits. I'm using the testnet and I want to buy ETH with 10% of my BTC balance.
With your commits (1.8.1):

>> {'symbol': 'ETHBTC', 'side': <Side.BUY: 'BUY'>, 'order_type': <OrderType.MARKET: 'MARKET'>, 'quote_order_quantity': Decimal('0.090569718')}
Task exception was never retrieved
future: <Task finished name='Task-11' coro=<BotsPooler.send_order() done, defined at ./botspooler.py:176> exception=BinanceError('Invalid quantity.')>
Traceback (most recent call last):
  File "./botspooler.py", line 178, in send_order
    order = await user.client.create_order(**kwargs)
  File "/nix/store/bg993hfs0dw6vqq1qfci9241950qgwn8-python3-3.8.9-env/lib/python3.8/site-packages/binance/client.py", line 368, in create_order
    return await self.http.send_api_call(route, "POST", data=params, signed=True)
  File "/nix/store/bg993hfs0dw6vqq1qfci9241950qgwn8-python3-3.8.9-env/lib/python3.8/site-packages/binance/http.py", line 84, in send_api_call
    return await self.handle_errors(response)
  File "/nix/store/bg993hfs0dw6vqq1qfci9241950qgwn8-python3-3.8.9-env/lib/python3.8/site-packages/binance/http.py", line 47, in handle_errors
    raise BinanceError(payload["msg"])
binance.errors.BinanceError: Invalid quantity.

With the previous build (1.8.0), I tried with even 1%:
{'symbol': 'ETHBTC', 'side': <Side.BUY: 'BUY'>, 'order_type': <OrderType.MARKET: 'MARKET'>, 'quote_order_quantity': Decimal('0.0090569718')}

and it worked perfectly.
Do you have any idea of what causes that issue? I will probably revert you commits for now.

Thomas

@ionsome
Copy link
Contributor

ionsome commented Jul 22, 2021

Hello @Th0rgal!

  1. Have you tried current build with 1%?
  2. Have you tried previous build with 10%?

@Th0rgal
Copy link
Owner Author

Th0rgal commented Jul 22, 2021

Hello @Th0rgal!

  1. Have you tried current build with 1%?
  2. Have you tried previous build with 10%?

Hey, I appreciate the quick answer!

Yes I did but because it worked one time with the second build, the quantity changed (1% of 100 is not 1% of 99), but I got a problem for every test with the new build and no problem at all with the previous one.

@ionsome
Copy link
Contributor

ionsome commented Jul 22, 2021

Yes I did but because it worked one time with the second build, the quantity changed (1% of 100 is not 1% of 99), but I got a problem for every test with the new build and no problem at all with the previous one.

We can be sure that the order creation request was sent and then server sent the error. There is can be a problem with the maximum quantity allowed.

Could you check what the client really send in send_api_call?

@Th0rgal
Copy link
Owner Author

Th0rgal commented Jul 22, 2021

Alright, I'm checking

Yes I did but because it worked one time with the second build, the quantity changed (1% of 100 is not 1% of 99), but I got a problem for every test with the new build and no problem at all with the previous one.

We can be sure that the order creation request was sent and then server sent the error. There is can be a problem with the maximum quantity allowed.

Could you check what the client really send in send_api_call?

When I print the refined_amount from the last version, I get 0.

If I use the previous version of refine_amount I get 0.00749773.

@ionsome
Copy link
Contributor

ionsome commented Jul 22, 2021

Whoops 👀
Tbh I don't remember why I make a special case for quote but it's a cause

amount = amount.quantize(decimal.Decimal(1), rounding=decimal.ROUND_DOWN)

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