Bybit bot problem

Joined
Jan 24, 2023
Messages
1
Reaction score
0
Hi,

i am quite new to programing . I wanted to create my own algo trading bot.

I have defined a minimum viable strategy i would like to test in the live market. For that i want to use Bybits testnet.
I have manged to connect to something but i can not interact with the testnet . To be honest i dont really understand what i am doing to connect.

I would be thankfull if you could help me achieve interaction with the servers so that i can run my test .

This is the code:

#specify URL of APi
api_url = "https://api-testnet.bybit.com"

#Funktion to crate a signal. No fucking idea what i am doing here.
def get_bybit_signature(urlpath,data,secret):
postdata = urllib.parse.urlencode(data)
encoded = (str(data['nonce'])+postdata).encode()
message = urlpath.encode() + hashlib.sha256(encoded).digest()

mac = hmac.new(base64.b64decode(secret), message, hashlib.sha512)
sigdigest = base64.b64encode(mac.digest())
return sigdigest.decode()

#request to pass trough get_kraken_signature
def bybit_request(url_path, data, api_key, api_sec):
headers = {"API-Key":api_key, "API-Sign":get_bybit_signature(url_path, data, api_sec)}
resp = requests.post((api_url + url_path), headers=headers, data = data)
return resp

resp= bybit_request("/spot/v1/account",{
"nonce": str(int(1000*time.time()))

}, api_key, api_sec )

print( resp.json())


and this is the error message
PS C:\Users\DV\Desktop\DOMA\Trading\Bot> & 'C:\Users\DV\Desktop\DOMA\Software\python.exe' 'c:\Users\DV\.vscode\extensions\ms-python.python-2022.20.2\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '60990' '--' 'c:\Users\DV\Desktop\DOMA\Trading\Bot\Buybit framework.py'
{'ret_code': -1004, 'ret_msg': "Missing required parameter ''", 'result': {}, 'ext_code': '', 'ext_info': None, 'time_now': '1674575653.755136'}
PS C:\Users\DV\Desktop\DOMA\Trading\Bot>


Thank you!
Have a good one
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top