(secret, verb, url, nonce, data)
return signature
Generate a request signature compatible with BitMEX.
Generate a request signature compatible with BitMEX.
Generate a request signature compatible with BitMEX .
def generate_signature(secret, verb, url, nonce, data):
    """Generate a request signature compatible with BitMEX."""
    # Parse the url so we can remove the base and extract just the path.
    parsedURL = urlparse(url)
    path = parsedURL.path
    if parsedURL.query:
        path = path + '?' + parsedURL.query

    # print "Computing HMAC: %s" % verb + path + str(nonce) + data
    message = verb + path + str(nonce) + data

    signature = hmac.new(bytes(secret, 'utf8'), bytes(message, 'utf8'), digestmod=hashlib.sha256).hexdigest()
    return signature
def generate_signature ( secret , verb , url , nonce , data ) : # Parse the url so we can remove the base and extract just the path. parsedURL = urlparse ( url ) path = parsedURL . path if parsedURL . query : path = path + '?' + parsedURL . query # print "Computing HMAC: %s" % verb + path + str(nonce) + data message = verb + path + str ( nonce ) + data signature = hmac . new ( bytes ( secret , 'utf8' ) , bytes ( message , 'utf8' ) , digestmod = hashlib . sha256 ) . hexdigest ( ) return signature