def header(self):
        """Return auth headers. Will use API Keys if present in settings."""
        auth_header = []

        if self.should_auth:
            alog.info("Authenticating with API Key.")
            # To auth to the WS using an API key, we generate a signature
            # of a nonce and the WS API endpoint.
            alog.debug(settings.BITMEX_API_KEY)
            nonce = generate_nonce()
            api_signature = generate_signature(settings.BITMEX_API_SECRET,
                                               'GET', '/realtime', nonce, '')

            auth_header = [
                "api-nonce: " + str(nonce), "api-signature: " + api_signature,
                "api-key:" + settings.BITMEX_API_KEY
            ]

        return auth_header
예제 #2
0
    def header(self):
        """Return auth headers. Will use API Keys if present in settings."""
        auth_header = []
        alog.info(f'### should auth {self.should_auth} ###')

        if self.should_auth:
            alog.info("Authenticating with API Key.")
            # To auth to the WS using an API key, we generate a signature
            # of a nonce and the WS API endpoint.
            alog.info((self.api_key, self.api_secret))

            nonce = generate_nonce()
            api_signature = generate_signature(self.api_secret, 'GET',
                                               '/realtime', nonce, '')

            auth_header = [
                "api-nonce: " + str(nonce), "api-signature: " + api_signature,
                "api-key:" + self.api_key
            ]

            alog.info(alog.pformat(auth_header))

        return auth_header