连接到Binance Spot Testnet API

huangapple go评论96阅读模式
英文:

Connection to Binance Spot Testnet API

问题

I'm working on a trading bot that actually works and I would like to try it for a week on the Binance testnet.

Despite all my research, I don't find a way to connect,

I already read all the Binance test net documentation

I'm sure about my API's

And this code is not working

  1. import ccxt
  2. import os
  3. from binance.client import Client
  4. api_key = os.environ.get('KEY')
  5. api_secret = os.environ.get('SECRET')
  6. client = Client(api_key, api_secret)
  7. client.API_URL = 'https://testnet.binance.vision/api'
  8. print(client.get_account())

This is the error that the code gives me

  1. Traceback (most recent call last):
  2. File "c:\Users\hp\Desktop\CODE\BOT CRYPTO\A) le BOT\les bots qui fonctionne\import ccxt.py", line 12, in <module>
  3. print(client.get_account())
  4. File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\binance\client.py", line 2052, in get_account
  5. return self._get('account', True, data=params)
  6. File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\binance\client.py", line 414, in _get
  7. return self._request_api('get', path, signed, version, **kwargs)
  8. File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\binance\client.py" return sig_func(query_string)
  9. File "C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\binance\client.py", line 258, in _hmac_signature assert self.API_SECRET, "API Secret required for private endpoints"
  10. AssertionError: API Secret required for private endpoints

If you have any information or solutions regarding my problem, I will gladly listen.

Thank you so much in advance

英文:

I'm working on a trading bot that actualy work and I would like to try it for a week on the Binance testnet.

Despite all my research, i don't find a way to connect,

I already read all the binance test net documentation

I'm sure about my API's

And this code is not working

  1. import ccxt
  2. import os
  3. from binance.client import Client
  4. api_key = os.environ.get(&#39;KEY&#39;)
  5. api_secret = os.environ.get(&#39;SECRET&#39;)
  6. client = Client(api_key, api_secret)
  7. client.API_URL = &#39;https://testnet.binance.vision/api&#39;
  8. print(client.get_account())

This is the Error that give me the code

  1. Traceback (most recent call last):
  2. File &quot;c:\Users\hp\Desktop\CODE\BOT CRYPTO\A) le BOT\les bots qui fonctionne\import ccxt.py&quot;, line 12, in &lt;module&gt;
  3. print(client.get_account())
  4. File &quot;C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\binance\client.py&quot;, line 2052, in get_account
  5. return self._get(&#39;account&#39;, True, data=params)
  6. File &quot;C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\binance\client.py&quot;, line 414, in _get
  7. return self._request_api(&#39;get&#39;, path, signed, version, **kwargs)
  8. File &quot;C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\binance\client.py&quot; return sig_func(query_string)
  9. File &quot;C:\Users\hp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\binance\client.py&quot;, line 258, in _hmac_signature assert self.API_SECRET, &quot;API Secret required for private endpoints&quot;
  10. AssertionError: API Secret required for private endpoints

If you have any information or solutions regarding my problem, I will gladly listen.

Thank you so much in advance

答案1

得分: 0

client = Client(api_key, api_secret, testnet=True)

英文:
  1. client = Client(api_key,api_secret, testnet=True)

huangapple
  • 本文由 发表于 2023年4月7日 04:58:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75953720.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定