コード例 #1
0
def generate_headers(api_secret, api_public, url, method, data):
    nonce = generate_nonce()
    headers = {
        "api-nonce":
        str(nonce),
        "api-signature":
        generate_signature(api_secret, method, url, nonce, json.dumps(data)),
        "api-key":
        api_public
    }
    return headers
コード例 #2
0
 def __get_auth(self):
     '''Return auth headers. Will use API Keys if present in settings.'''
     if self.api_key:
         self.logger.info("Authenticating with API Key.")
         # Refer to BitMEX/sample-market-maker on Github
         expires = int(round(time.time()) + 5)  # 5s grace period in case of clock skew
         return [
             "api-expires: " + str(expires),
             "api-signature: " + generate_signature(self.api_secret, 'GET', '/realtime', expires, ''),
             "api-key:" + self.api_key
         ]
     else:
         self.logger.info("Not authenticating.")
         return []
コード例 #3
0
 def __get_auth(self):
     """Return auth headers. Will use API Keys if present in settings."""
     if self.api_key:
         self.logger.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.
         nonce = generate_nonce()
         return [
             "api-nonce: " + str(nonce),
             "api-signature: " + generate_signature(self.api_secret, 'GET', '/realtime', nonce, ''),
             "api-key:" + self.api_key
         ]
     else:
         self.logger.info("Not authenticating.")
         return []
コード例 #4
0
 def __get_auth(self):
     '''Return auth headers. Will use API Keys if present in settings.'''
     if self.api_key:
         self.logger.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.
         expires = generate_nonce()
         return [
             "api-expires: " + str(expires),
             "api-signature: " + generate_signature(self.api_secret, 'GET', '/api/v1/signature', expires, ''),
             "api-key:" + self.api_key
         ]
     else:
         self.logger.info("Not authenticating.")
         return []
コード例 #5
0
 def __get_auth(self):
     '''Return auth headers. Will use API Keys if present in settings.'''
     if self.config['api_key']:
         self.logger.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.
         nonce = generate_nonce()
         return [
             "api-nonce: " + str(nonce),
             "api-signature: " + generate_signature(self.config['api_secret'], 'GET', '/realtime', nonce, ''),
             "api-key:" + self.config['api_key']
         ]
     else:
         self.logger.info("Not authenticating.")
         return []
コード例 #6
0
 def __get_auth(self):
     '''Return auth headers. Will use API Keys if present in settings.'''
     if self.api_key:
         self.logger.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.
         expires = self.__generate_nonce()
         return [("api-expires", expires),
                 ("api-signature",
                  generate_signature(self.api_secret, 'GET',
                                     '/realtime', expires, '')),
                 ("api-key", self.api_key)]
     else:
         self.logger.info("Not authenticating.")
         return []
コード例 #7
0
 def __get_auth(self):
     '''Return auth headers. Will use API Keys if present in settings.'''
     if self.config['api_key']:
         print("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.
         nonce = generate_nonce()
         return [
             "api-nonce: " + str(nonce),
             "api-signature: " + generate_signature(
                 self.config['api_secret'], 'GET', '/realtime', nonce, ''),
             "api-key:" + self.config['api_key']
         ]
     else:
         print("Not authenticating.")
         return []
コード例 #8
0
 def __get_auth(self):
     '''Return auth headers. Will use API Keys if present in settings.'''
     if not self.config['api_key']:
         self.logger.info("Authenticating with email/password.")
         return [
             "email: " + self.config['login'],
             "password: "******"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.
         nonce = generate_nonce()
         return [
             "api-nonce: " + str(nonce),
             "api-signature: " + generate_signature(
                 self.config['api_secret'], 'GET', '/realtime', nonce, ''),
             "api-key:" + self.config['api_key']
         ]