连接到Binance Spot Testnet API

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

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

import ccxt
import os
from binance.client import Client

api_key = os.environ.get('KEY')
api_secret = os.environ.get('SECRET')
client = Client(api_key, api_secret)

client.API_URL = 'https://testnet.binance.vision/api'

print(client.get_account())

This is the error that the code gives me

Traceback (most recent call last):
  File "c:\Users\hp\Desktop\CODE\BOT CRYPTO\A)   le BOT\les bots qui fonctionne\import ccxt.py", line 12, in <module>
    print(client.get_account())
  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
    return self._get('account', True, data=params)
  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
    return self._request_api('get', path, signed, version, **kwargs)
  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)
  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"
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

import ccxt
import os
from binance.client import Client


api_key = os.environ.get(&#39;KEY&#39;)
api_secret = os.environ.get(&#39;SECRET&#39;)
client = Client(api_key, api_secret)

client.API_URL = &#39;https://testnet.binance.vision/api&#39;

print(client.get_account())

This is the Error that give me the code

Traceback (most recent call last):
  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;
    print(client.get_account())
  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
    return self._get(&#39;account&#39;, True, data=params)
  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
    return self._request_api(&#39;get&#39;, path, signed, version, **kwargs)
  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)
  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;
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)

英文:
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:

确定