def spot_get_market_summary(): url = "/api/{0}/market_summary".format(get_spot_api_version()) env = get_env_info() ret = {} try: resp = requests.get(get_spot_full_url(env["API_HOST"], url)) resp.raise_for_status() except HTTPError as http_err: print("HTTP error occurred: {0}".format(http_err)) except Exception as err: print("Other error occurred: {0}".format(err)) else: ret = resp.json() return ret
def earn_get_orders(): url = "/api/{0}/invest/orders".format(get_spot_api_version()) env = get_env_info() headers = gen_headers(env["API_KEY"], env["API_SECRET_KEY"], url) ret = {} try: resp = requests.get(get_spot_full_url(env["API_HOST"], url), headers=headers) resp.raise_for_status() except HTTPError as http_err: print("HTTP error occurred: {0}".format(http_err)) except Exception as err: print("Other error occurred: {0}".format(err)) else: ret = resp.json() return ret
def spot_place_limit_order(data): url = "/api/{0}/order".format(get_spot_api_version()) env = get_env_info() headers = gen_headers(env["API_KEY"], env["API_SECRET_KEY"], url, json.dumps(data)) ret = {} try: resp = requests.post(get_spot_full_url(env["API_HOST"], url), json=data, headers=headers) resp.raise_for_status() except HTTPError as http_err: print("HTTP error occurred: {0}".format(http_err)) except Exception as err: print("Other error occurred: {0}".format(err)) else: ret = resp.json() return ret
def spot_get_wallet_address(currency): url = "/api/{0}/user/wallet/address".format(get_spot_api_version()) env = get_env_info() headers = gen_headers(env["API_KEY"], env["API_SECRET_KEY"], url) ret = {} params = {"currency": currency} try: resp = requests.get( get_spot_full_url(env["API_HOST"], url), params=params, headers=headers, ) resp.raise_for_status() except HTTPError as http_err: print("HTTP error occurred: {0}".format(http_err)) except Exception as err: print("Other error occurred: {0}".format(err)) else: ret = resp.json() return ret
def earn_get_history(page_number=1, page_size=10): url = "/api/{0}/invest/history".format(get_spot_api_version()) env = get_env_info() headers = gen_headers(env["API_KEY"], env["API_SECRET_KEY"], url) params = { "pageNumber": page_number, "pageSize": page_size, } ret = {} try: # page_number is 1-based resp = requests.get( get_spot_full_url(env["API_HOST"], url), params=params, headers=headers, ) resp.raise_for_status() except HTTPError as http_err: print("HTTP error occurred: {0}".format(http_err)) except Exception as err: print("Other error occurred: {0}".format(err)) else: ret = resp.json() return ret