MohammedRashad / Crypto-Copy-Trader

A copy trading tool for cryptocurrencies - Binance Exchange
Apache License 2.0
202 stars 86 forks source link

Error MIN_NOTIONAL Invalid quantity #41

Closed alexandrebouttier closed 3 years ago

alexandrebouttier commented 3 years ago

Hello, I encounter a bug, when I launch an order on master, quantity problem with my slave even though he has the necessary funds to place an order, here are my logs

2020-12-23 10:10:36,499 - INFO - The Crypto-Copy-Trader starts launch 2020-12-23 10:10:36,499 - INFO - Reading configuration file... 2020-12-23 10:10:36,499 - INFO - 1 Slave accounts detected 2020-12-23 10:10:36,501 - INFO - Connecting to the master: KeyALex... 2020-12-23 10:10:37,587 - INFO - Connecting to the slaves. Its can take time... 2020-12-23 10:10:38,876 - INFO - Open masters websocket... 2020-12-23 10:10:39,121 - INFO - Launch complete. Now I can copy orders! 2020-12-23 10:11:24,388 - DEBUG - Event came: {'e': 'executionReport', 'E': 1608714684262, 's': 'ETHUSDT', 'c': 'xxxxx', 'S': 'BUY', 'o': 'MARKET', 'f': 'GTC', 'q': '0.16315000', 'p': '0.00000000', 'P': '0.00000000', 'F': '0.00000000', 'g': -1, 'C': '', 'x': 'NEW', 'X': 'NEW', 'r': 'NONE', 'i': 2325685997, 'l': '0.00000000', 'z': '0.00000000', 'L': '0.00000000', 'n': '0', 'N': None, 'T': 1608714684260, 't': -1, 'I': 4865731139, 'w': True, 'm': False, 'M': False, 'O': 1608714684260, 'Z': '0.00000000', 'Y': '0.00000000', 'Q': '100.00000000'} 2020-12-23 10:11:24,389 - DEBUG - Event came: {'e': 'executionReport', 'E': 1608714684262, 's': 'ETHUSDT', 'c': 'xxxxx', 'S': 'BUY', 'o': 'MARKET', 'f': 'GTC', 'q': '0.16315000', 'p': '0.00000000', 'P': '0.00000000', 'F': '0.00000000', 'g': -1, 'C': '', 'x': 'TRADE', 'X': 'FILLED', 'r': 'NONE', 'i': 2325685997, 'l': '0.16315000', 'z': '0.16315000', 'L': '612.93000000', 'n': '0.00226259', 'N': 'BNB', 'T': 1608714684260, 't': 227902861, 'I': 4865731140, 'w': False, 'm': False, 'M': True, 'O': 1608714684260, 'Z': '99.99952950', 'Y': '99.99952950', 'Q': '100.00000000'} 2020-12-23 10:11:24,389 - DEBUG - Event came: {'e': 'outboundAccountInfo', 'E': 1608714684262, 'm': 10, 't': 10, 'b': 0, 's': 0, 'T': True, 'W': True, 'D': True, 'u': 1608714684260, 'B': [{'a': 'ETH', 'f': '0.19602369', 'l': '0.00000000'}, {'a': 'BNB', 'f': '0.00669054', 'l': '0.00000000'}, {'a': 'USDT', 'f': '6320.77495381', 'l': '0.00000000'}], 'P': ['SPOT', 'LEVERAGED']} 2020-12-23 10:11:24,622 - INFO -

2020-12-23 10:11:24,623 - INFO - New action came: {'exchange': 'Binance', 'name': 'new_order', 'order': Order: id: 2325685997price: 612.93000000, symbol: ETHUSDT, amount: 0.16315000, part: 0.015418628151843191, side: BUY, type: MARKET,} 2020-12-23 10:11:24,624 - INFO - Slave mhamed {'asset': 'USDT', 'free': '123.81576397', 'locked': '0.00000000'} {'asset': 'ETH', 'free': '0.00000000', 'locked': '0.00000000'}, Create Order: amount: 0.00311, price: 612.93000000 2020-12-23 10:11:24,876 - ERROR - APIError(code=-1013): Filter failure: MIN_NOTIONAL 2020-12-23 10:11:24,877 - DEBUG - Event came: {'e': 'outboundAccountPosition', 'E': 1608714684262, 'u': 1608714684260, 'B': [{'a': 'ETH', 'f': '0.19602369', 'l': '0.00000000'}, {'a': 'BNB', 'f': '0.00669054', 'l': '0.00000000'}, {'a': 'USDT', 'f': '6320.77495381', 'l': '0.00000000'}]} 2020-12-23 10:15:08,389 - DEBUG - Event came: {'e': 'executionReport', 'E': 1608714908258, 's': 'ETHUSDT', 'c': 'xxxxx', 'S': 'SELL', 'o': 'MARKET', 'f': 'GTC', 'q': '0.19601000', 'p': '0.00000000', 'P': '0.00000000', 'F': '0.00000000', 'g': -1, 'C': '', 'x': 'NEW', 'X': 'NEW', 'r': 'NONE', 'i': 2325706924, 'l': '0.00000000', 'z': '0.00000000', 'L': '0.00000000', 'n': '0', 'N': None, 'T': 1608714908257, 't': -1, 'I': 4865773912, 'w': True, 'm': False, 'M': False, 'O': 1608714908257, 'Z': '0.00000000', 'Y': '0.00000000', 'Q': '120.22000000'} 2020-12-23 10:15:08,390 - DEBUG - Event came: {'e': 'executionReport', 'E': 1608714908258, 's': 'ETHUSDT', 'c': 'xxxxx', 'S': 'SELL', 'o': 'MARKET', 'f': 'GTC', 'q': '0.19601000', 'p': '0.00000000', 'P': '0.00000000', 'F': '0.00000000', 'g': -1, 'C': '', 'x': 'TRADE', 'X': 'PARTIALLY_FILLED', 'r': 'NONE', 'i': 2325706924, 'l': '0.03260000', 'z': '0.03260000', 'L': '613.34000000', 'n': '0.00045189', 'N': 'BNB', 'T': 1608714908257, 't': 227903918, 'I': 4865773913, 'w': False, 'm': False, 'M': True, 'O': 1608714908257, 'Z': '19.99488400', 'Y': '19.99488400', 'Q': '120.22000000'} 2020-12-23 10:15:08,391 - DEBUG - Event came: {'e': 'executionReport', 'E': 1608714908258, 's': 'ETHUSDT', 'c': 'xxxx, 'S': 'SELL', 'o': 'MARKET', 'f': 'GTC', 'q': '0.19601000', 'p': '0.00000000', 'P': '0.00000000', 'F': '0.00000000', 'g': -1, 'C': '', 'x': 'TRADE', 'X': 'FILLED', 'r': 'NONE', 'i': 2325706924, 'l': '0.16341000', 'z': '0.19601000', 'L': '613.33000000', 'n': '0.00226513', 'N': 'BNB', 'T': 1608714908257, 't': 227903919, 'I': 4865773915, 'w': False, 'm': False, 'M': True, 'O': 1608714908257, 'Z': '120.21913930', 'Y': '100.22425530', 'Q': '120.22000000'} 2020-12-23 10:15:08,392 - DEBUG - Event came: {'e': 'outboundAccountInfo', 'E': 1608714908258, 'm': 10, 't': 10, 'b': 0, 's': 0, 'T': True, 'W': True, 'D': True, 'u': 1608714908257, 'B': [{'a': 'ETH', 'f': '0.00001369', 'l': '0.00000000'}, {'a': 'BNB', 'f': '0.00397352', 'l': '0.00000000'}, {'a': 'USDT', 'f': '6440.99409311', 'l': '0.00000000'}], 'P': ['SPOT', 'LEVERAGED']} 2020-12-23 10:15:08,640 - INFO -

2020-12-23 10:15:08,640 - INFO - New action came: {'exchange': 'Binance', 'name': 'new_order', 'order': Order: id: 2325706924price: 613.32000000, symbol: ETHUSDT, amount: 0.19601000, part: 0.9899308598873942, side: SELL, type: MARKET,} 2020-12-23 10:15:08,641 - INFO - Slave mhamed {'asset': 'USDT', 'free': '123.81576397', 'locked': '0.00000000'} {'asset': 'ETH', 'free': '0.00000000', 'locked': '0.00000000'}, Create Order: amount: 0.0, price: 613.32000000 2020-12-23 10:15:08,877 - ERROR - APIError(code=-1013): Invalid quantity. 2020-12-23 10:15:08,879 - DEBUG - Event came: {'e': 'outboundAccountPosition', 'E': 1608714908258, 'u': 1608714908257, 'B': [{'a': 'ETH', 'f': '0.00001369', 'l': '0.00000000'}, {'a': 'BNB', 'f': '0.00397352', 'l': '0.00000000'}, {'a': 'USDT', 'f': '6440.99409311', 'l': '0.00000000'}]} 2020-12-23 10:16:01,922 - DEBUG - Event came: {'e': 'executionReport', 'E': 1608714961790, 's': 'ETHUSDT', 'c': 'xxxxx', 'S': 'BUY', 'o': 'MARKET', 'f': 'GTC', 'q': '0.14697000', 'p': '0.00000000', 'P': '0.00000000', 'F': '0.00000000', 'g': -1, 'C': '', 'x': 'NEW', 'X': 'NEW', 'r': 'NONE', 'i': 2325713320, 'l': '0.00000000', 'z': '0.00000000', 'L': '0.00000000', 'n': '0', 'N': None, 'T': 1608714961787, 't': -1, 'I': 4865786962, 'w': True, 'm': False, 'M': False, 'O': 1608714961787, 'Z': '0.00000000', 'Y': '0.00000000', 'Q': '90.00000000'} 2020-12-23 10:16:01,923 - DEBUG - Event came: {'e': 'executionReport', 'E': 1608714961790, 's': 'ETHUSDT', 'c': 'xxxxx', 'S': 'BUY', 'o': 'MARKET', 'f': 'GTC', 'q': '0.14697000', 'p': '0.00000000', 'P': '0.00000000', 'F': '0.00000000', 'g': -1, 'C': '', 'x': 'TRADE', 'X': 'FILLED', 'r': 'NONE', 'i': 2325713320, 'l': '0.14697000', 'z': '0.14697000', 'L': '612.35000000', 'n': '0.00203682', 'N': 'BNB', 'T': 1608714961787, 't': 227904205, 'I': 4865786963, 'w': False, 'm': False, 'M': True, 'O': 1608714961787, 'Z': '89.99707950', 'Y': '89.99707950', 'Q': '90.00000000'} 2020-12-23 10:16:01,923 - DEBUG - Event came: {'e': 'outboundAccountInfo', 'E': 1608714961790, 'm': 10, 't': 10, 'b': 0, 's': 0, 'T': True, 'W': True, 'D': True, 'u': 1608714961787, 'B': [{'a': 'ETH', 'f': '0.14698369', 'l': '0.00000000'}, {'a': 'BNB', 'f': '0.00193670', 'l': '0.00000000'}, {'a': 'USDT', 'f': '6350.99701361', 'l': '0.00000000'}], 'P': ['SPOT', 'LEVERAGED']} 2020-12-23 10:16:02,160 - INFO -

mokolotron commented 3 years ago

Most likely, there are problems in the ratio of balances on master and slave accounts. For example, an order of about ~ $ 100 was created on the master, and the free balance of USDT was ~ $ 6500. Then it turns out that the master created an order for ~ 1.5%. Then the slave calculates its size from ~ 1.5% and the maximimum of his own free USDT balance. The problem is that the maximum available balance on the slave = $ 123 This means that 1.5% of 123$ is 1.85$, which is less than the minimum order for binance.

Probably, to eliminate this problem in the project, you need to add the condition that if the order is less than the minimum value, then place an order with the minimum value.

Or if you want to solve the problem now, then bind accounts only with approximately the same balances.

If I was mistaken, both the master and slave accounts already had approximately the same amount of USDT, please then let me know.

alexandrebouttier commented 3 years ago

Thank you for your answer, to get around the problem the master has a lower sum than the slaves, then why not put an allocation variable to calculate in% the balance allocated for the slaves