I am currently trying to automate my Tradingview script to trigger trades automatically on Binance. To do so, I am following a tutorial that is using the python-binance module. It was quite simple as a new Python programmer. However, when I started testing it using my API, I’ve come across error “code=-2015” that I cannot get rid of. I know there are many references on this page as well as on the internet, but I am still facing this issue. Also, I would like to understand that library more.
So, I went through the bullet points listed here.
client = Client(config.API_KEY, config.API_SECRET)
order = client.create_order(symbol=symbol, side=side, type=order_type, quantity=quantity)
After further investigations, it seems the issue is related to the fact that the python-binance module is using the SPOT url (https://api.binance.com/api) instead of the Futures one (https://fapi.binance.com/fapi).
Note: I am using Futures, and my API key is correct as well as its permissions because it works fine on MT4 without any issues, but I would like to move to Tradingview. The only API options checked are: Enable Reading, Enable Futures, Unrestricted (Less Secure).
So, my logical thinking suggests that python-binance is using SPOT url by default, but I don’t know where to change that. How do I force it to using Futures ? Where is that configured ? How does the python-binance module know which environment to use based on the API key ?
A little bit longer text than initially thought but my aim is to fix this issue and then understand a little more about the module itself. Some threads suggest changing binance_f/constant/system.py, but I don’t have such a file at all. Also, others suggest adding the url parameter (url=‘https://fapi.binance.com’) to the Client call, but there is no such a parameter either. Files related to the Python module seem to be located under C:\Users\Administrator\AppData\Local\Programs\Python\Python310\Lib\site-packages\binance that is what I’ve established so far.
Thanks in advance for your inputs.