PostOrder causing "Invalid timeInForce" error

Hi I’m made a post order on binance testnet using ccxt but I’m getting an Invalid timeInForce error.
I have set timeInForce to PostOnly in my params but I’m still encountering the same issue.

Here is my code :
binance.create_limit_buy_order(‘BTC/USDT’,0.1,23732, params={‘timeInForce’:‘PostOnly’,})

And I’m getting this error:
File “C:\Users\juhok\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ccxt\base\exchange.py”, line 625, in fetch
response.raise_for_status()
File “C:\Users\juhok\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\models.py”, line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://testnet.binancefuture.com/fapi/v1/order

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “c:\Users\juhok\OneDrive\Desktop\Auto Trading\1st_bot.py”, line 140, in
binance.create_limit_buy_order(‘BTC/USDT’,0.1,23732, params={‘timeInForce’:‘PostOnly’,})
File “C:\Users\juhok\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ccxt\base\exchange.py”, line 3278, in create_limit_buy_order
return self.create_order(symbol, ‘limit’, ‘buy’, amount, price, params)
File “C:\Users\juhok\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ccxt\binance.py”, line 3468, in create_order
response = getattr(self, method)(self.extend(request, requestParams))
File “C:\Users\juhok\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ccxt\base\exchange.py”, line 505, in inner
return entry(_self, **inner_kwargs)
File “C:\Users\juhok\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ccxt\binance.py”, line 6201, in request
response = self.fetch2(path, api, method, params, headers, body, config, context)
File “C:\Users\juhok\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ccxt\base\exchange.py”, line 2830, in fetch2
return self.fetch(request[‘url’], request[‘method’], request[‘headers’], request[‘body’])
File “C:\Users\juhok\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ccxt\base\exchange.py”, line 641, in fetch
skip_further_error_handling = self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
File “C:\Users\juhok\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ccxt\binance.py”, line 6179, in handle_errors
self.throw_exactly_matched_exception(self.exceptions[‘exact’], error, feedback)
File “C:\Users\juhok\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ccxt\base\exchange.py”, line 3133, in throw_exactly_matched_exception
raise exactstring
ccxt.base.errors.BadRequest: binance {“code”:-1115,“msg”:“Invalid timeInForce.”}

What am I missing here?

It says in your error message that it was an Invalid timeInForce value.

Based on the exchangeInfo for FAPI in Testnet for the symbol in question, the supported Time in Force values are

        "timeInForce": [
            "GTC",
            "IOC",
            "FOK",
            "GTX"
        ]
    },

Please refer to the Binance API Documentation documentation to see which TimeInForce enum suits your requirements.