gateio / gateapi-python

263 stars 97 forks source link

Problem with open field in OHLCV #163

Open BMMAIA95 opened 2 months ago

BMMAIA95 commented 2 months ago

Hey guys!

I'm building a script in Python that returns the value of the OPEN field when using OHLCV, however, when I run the code it returns a value that I don't understand. Could anyone help me please?

This is the code:

import gate_api
from gate_api.exceptions import ApiException, GateApiException
# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
    host = "https://api.gateio.ws/api/v4"
)

api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.SpotApi(api_client)
currency_pair = 'SOL_USDT' # str | Currency pair
limit = 100 # int | Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. (optional) (default to 100)
_from = 1725526800 # int | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified (optional)
to = 1725526800 # int | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time (optional)
interval = '1d' # str | Interval time between data points. Note that `30d` means 1 natual month, not 30 days (optional) (default to '30m')

try:
    # Market candlesticks
    api_response = api_instance.list_candlesticks(currency_pair, limit=limit, _from=_from, to=to, interval=interval)
    print(api_response)
except GateApiException as ex:
    print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
    print("Exception when calling SpotApi->list_candlesticks: %s\n" % e)
This is the result:

Captura de tela 2024-09-05 114654

revilwang commented 2 months ago

You can find the response explanation here

BMMAIA95 commented 2 months ago

You can find the response explanation here

Thanks for the answer. I looked at the page you mentioned and found an explanation of why this happens, but where do I find the solution? How do I convert this value to USDT for example? In the document exemple it is also like this and it does not show how to solve