gateio / gateapi-python

250 stars 93 forks source link

Authorized api gives `Missing required header: Timestamp` error while placing spot order #147

Open astr0gator opened 1 year ago

astr0gator commented 1 year ago
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"}