Am using from delta_rest_client import DeltaRestClient to place order this is my actual code.
from delta_rest_client import DeltaRestClient
def place_order():
response = delta_client.place_order(
product_id=27,
size=0.1,
side='buy'
)
Getting below Error:
HTTPError: 401 HTTP Error: Unauthorized {"error":{"code":"expired_signature","context":{"request_time":1741207371,"server_time":1741206574}},"success":false} for url: https://api.india.delta.exchange/v2/orders
Then i tried working with http request below code.
def generate_signature(secret, message):
message = bytes(message, 'utf-8')
secret = bytes(secret, 'utf-8')
hash = hmac.new(secret, message, hashlib.sha256)
return hash.hexdigest()
def place_order():
base_url = 'https://api.india.delta.exchange'
api_key = ''
api_secret = ''
method = 'POST'
timestamp = str(int(time.time()))
path = '/v2/orders'
url = f'{base_url}{path}'
order_payload = {
"order_type":"limit_order",
"size":0.1,
"side":"buy",
"limit_price":0.005,
"product_id":27
}
payload = json.dumps(order_payload)
print(payload)
signature_data = method + timestamp + path + payload
signature = generate_signatureNew(api_secret, signature_data)
req_headers = {
'api-key': api_key,
'timestamp': timestamp,
'signature': signature,
'User-Agent': 'rest-client',
'Content-Type': 'application/json'
}
response = requests.request(method, url, data=payload, params={}, timeout=(3, 27), headers=req_headers)
print(response.json())
Getting below Error:
{'error': {'code': 'expired_signature', 'context': {'request_time': 1741208402, 'server_time': 1741207605}}, 'success': False}