gateio / gateapi-python

247 stars 92 forks source link

SpotApi->list_currency_pairs这个函数今天突然不能用了!报以下错误! #72

Closed yazhoushi closed 2 years ago

yazhoushi commented 2 years ago

Exception when calling SpotApi->list_currency_pairs: (401) Reason: Unauthorized HTTP response headers: HTTPHeaderDict({'Date': 'Mon, 27 Sep 2021 04:57:55 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty'}) HTTP response body: {"label":"MISSING_REQUIRED_HEADER","message":"Missing required header: Timestamp"}

revilwang commented 2 years ago

该问题在解除对这该接口单独的限速时引入,已恢复

astr0gator commented 1 year ago

Have same issue. Any ideas?

This code works: tickers = spot_api.list_tickers(currency_pair=currency_pair)

This one gives an error: order = Order( amount=str(0.05), side="buy", currency_pair=currency_pair ) spot_api.create_order(order)

*** gate_api.exceptions.GateApiException: (400) Reason: Bad Request HTTP response headers: HTTPHeaderDict({'Date': 'Tue, 11 Apr 2023 10:30:28 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty'}) HTTP response body: {"message":"Missing required header: Timestamp","label":"MISSING_REQUIRED_HEADER"}

revilwang commented 1 year ago

create_order is a private endpoint. You need to setup your API key and secret before invoking it.

astr0gator commented 1 year ago

Thank you so much. I submitted an issue with authorized API

import gate_api
from gate_api import ApiClient, Configuration, Order, SpotApi

configuration = gate_api.Configuration(
            host = "https://api.gateio.ws/api/v4",
            key = GATE_IO_API_KEY,
            secret = GATE_IO_SECRET
        )
api_client = gate_api.ApiClient(configuration)
api_instance = gate_api.SpotApi(api_client)
    def market_buy_gate_io(cls, symbol):
        currency_pair = symbol + "_" + cls.quote_asset

        order = gate_api.Order(
            amount=str(0.05), side="buy", currency_pair="ETH_USDT"
        )
        executed_trade = api_instance.create_order(order)
        return executed_trade

Produces:

*** gate_api.exceptions.GateApiException: (400) Reason: Bad Request HTTP response headers: HTTPHeaderDict({'Date': 'Tue, 11 Apr 2023 10:30:28 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty'}) HTTP response body: {"message":"Missing required header: Timestamp","label":"MISSING_REQUIRED_HEADER"}