So here is the problem I am facing.
Using python binance-futures-connector I am trying to integrate my custom trading bot into binance.
Currently as I will be testing it first, I am connecting to testnet.binancefuture.com
While testing i managed to post orders, but never seen ANYTHING on the web view in testnet.binancefuture.com:
Notice order history is empty in the screenshot
Notice the order history from my code below:
...
cm_futures_client = CMFutures(key='***', secret='***', base_url='https://testnet.binancefuture.com')
...
{'serverTime': 1736982936367}
{'feeTier': 0, 'canTrade': True, 'canDeposit': True, 'canWithdraw': True, 'updateTime': 0, 'assets': [{'asset': 'CHZ', 'walletBalance': '0.00000000', 'unrealizedProfit': '0.00000000', 'marginBalance': '0.00000000', 'maintMargin': '0.00000000', 'initialMargin': '0.00000000', 'positionInitialMargin': '0.00000000', 'openOrderInitialMargin': '0.00000000', 'maxWithdrawAmount': '0.00000000', 'crossWalletBalance': '0.00000000', 'crossUnPnl': '0.00000000', 'availableBalance': '0.00000000', 'updateTime': 0}, {'asset': 'CRV', 'walletBalance': '0.00000000', 'unrealizedProfit': '0.00000000', 'marginBalance': '0.00000000', 'maintMargin': '0.00000000', 'initialMargin': '0.00000000', 'positionInitialMargin': '0.00000000', 'openOrderInitialMargin': '0.00000000', 'maxWithdrawAmount': '0.00000000', 'crossWalletBalance': '0.00000000', 'crossUnPnl': '0.00000000', 'availableBalance': '0.00000000', 'updateTime': 0}, {'asset': 'BTC', 'walletBalance': '10.00000000', 'unrealizedProfit': '0.00000000', 'marginBalance': '10.00000000', 'maintMargin': '0.00000000', 'initialMargin': '0.00000000', 'positionInitialMargin': '0.00000000', 'openOrderInitialMargin': '0.00000000', 'maxWithdrawAmount': '10.00000000', 'crossWalletBalance': '10.00000000', 'crossUnPnl': '0.00000000', 'availableBalance': '10.00000000', 'updateTime': 1732323557386}, ... , {'symbol': 'LTCUSD_250328', 'initialMargin': '0', 'maintMargin': '0', 'unrealizedProfit': '0.00000000', 'positionInitialMargin': '0', 'openOrderInitialMargin': '0', 'leverage': '20', 'isolated': False, 'positionSide': 'BOTH', 'entryPrice': '0.00000000', 'maxQty': '5000', 'notionalValue': '0', 'isolatedWallet': '0', 'updateTime': 0, 'positionAmt': '0', 'breakEvenPrice': '0.00000000'}]}
DOTUSD_250328
WIFUSD_PERP
CHZUSD_PERP
LINKUSD_PERP
...
ALGOUSD_PERP
LTCUSD_250328
[{'orderId': 604675492, 'symbol': 'BTCUSD_PERP', 'pair': 'BTCUSD', 'status': 'CANCELED', 'clientOrderId': 'Ns6cTnQCoohbEr8bmesmwv', 'price': '96760', 'avgPrice': '0.0', 'origQty': '2', 'executedQty': '0', 'cumBase': '0', 'timeInForce': 'GTC', 'type': 'LIMIT', 'reduceOnly': False, 'closePosition': False, 'side': 'SELL', 'positionSide': 'BOTH', 'stopPrice': '0', 'workingType': 'CONTRACT_PRICE', 'priceProtect': False, 'priceMatch': 'NONE', 'selfTradePreventionMode': 'NONE', 'origType': 'LIMIT', 'time': 1736899528274, 'updateTime': 1736900713947}, {'orderId': 604675503, 'symbol': 'BTCUSD_PERP', 'pair': 'BTCUSD', 'status': 'CANCELED', 'clientOrderId': 'nWJ2V94ooaXLXvuKeWZQ0N', 'price': '96760', 'avgPrice': '0.0', 'origQty': '2', 'executedQty': '0', 'cumBase': '0', 'timeInForce': 'GTC', 'type': 'LIMIT', 'reduceOnly': False, 'closePosition': False, 'side': 'SELL', 'positionSide': 'BOTH', 'stopPrice': '0', 'workingType': 'CONTRACT_PRICE', 'priceProtect': False, 'priceMatch': 'NONE', 'selfTradePreventionMode': 'NONE', 'origType': 'LIMIT', 'time': 1736899589959, 'updateTime': 1736900713947}]
Found error. status: 400, error code: -2011, error message: Unknown order sent.
Found error. status: 400, error code: -2011, error message: Unknown order sent.
{'code': 200, 'msg': 'The operation of cancel all open order is done.'}
END ORDERS
Traceback (most recent call last):
File "C:\Users\...\Desktop\flash\coingate\biance-connect.py", line 73, in <module>
response = cm_futures_client.new_order(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\...\Desktop\flash\coingate\env\Lib\site-packages\binance\cm_futures\account.py", line 77, in new_order
return self.sign_request("POST", url_path, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\...\Desktop\flash\coingate\env\Lib\site-packages\binance\api.py", line 83, in sign_request
return self.send_request(http_method, url_path, payload, special)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\...\Desktop\flash\coingate\env\Lib\site-packages\binance\api.py", line 118, in send_request
self._handle_exception(response)
File "C:\Users\...\Desktop\flash\coingate\env\Lib\site-packages\binance\api.py", line 172, in _handle_exception
raise ClientError(status_code, err["code"], err["msg"], response.headers)
binance.error.ClientError: (400, -4024, "Limit price can't be lower than 194.179", {'Content-Type': 'application/json', 'Content-Length': '62', 'Connection': 'keep-alive', 'Date': 'Wed, 15 Jan 2025 23:15:40 GMT', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', 'Server': 'Bengine', 'x-mbx-used-weight-1m': '-1', 'x-mbx-order-count-1m': '1', 'x-response-time': '1ms', 'Access-Control-Allow-Origin': '*', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 923c2d2f00d1c4aa09564e5db1f3c7a8.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'LIS50-P1', 'X-Amz-Cf-Id': 'tb7giO75H9pL1Z_Pb0cMdMrPMqWbgqH0J51lLp_Jk1NddRnst9FIIA=='})
What is really bothering me is that 1:
API key matches 100%. It works and connects.
I managed to post 2 orders yesterday, but in the webview my margin is still the initial since I opened the account - 15000$ Testnet
When I try to post another order right now, through my code, I always get “Insufficient margin” error.
THE API KEY IS THE CORRECT ONE.
I am not sure if I’m doing something wrong or binance simply does not show bot trades in the normal history… (at least on testnet?)
Somebody who’s been around and found out, please help me