Beispiel #1
0
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
import pandas as pd

# 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)

try:
    # Retrieve ticker information
    api_response = api_instance.list_tickers()

    col_names = []
    rows = []
    for i, m in enumerate(api_response):
        if i == 0:
            col_names = [k for k in m.attribute_map.keys()]
        row = [getattr(m, cn) for cn in col_names]
        rows.append(row)

    df = pd.DataFrame(rows)
    df.columns = col_names
    df.to_csv("~/Desktop/tickers.csv", sep="\t", index=False)

except GateApiException as ex:
    print(f"Gate api exception, label: {ex.label}, message: {ex.message}")
Beispiel #2
0
    def __init__(self, account_secret):
        super().__init__(account_secret)

        self.conf = gate_api.Configuration()
        self.conf.key, self.conf.secret = account_secret.api_key, account_secret.api_secret
Beispiel #3
0
from decimal import Decimal

import gate_api
import hmac, hashlib, base64
import requests
import time
from src.models.prices import ExchangeQuote
from src.api.classes import SpotBalances


configuration = gate_api.Configuration(
    key="[redacted]",
    secret="[redacted]"
)

api_client = gate_api.ApiClient(configuration)

wallet_api = gate_api.WalletApi(api_client)
spot_api = gate_api.SpotApi(api_client)


def place_gate_order(amount, price, side):
    order = gate_api.Order(
        currency_pair="UNN_USDT",
        type="limit",
        amount=amount,
        side=side,
        price=price,
        time_in_force="ioc"
    )
Beispiel #4
0
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, GateApiException
from my_secrets import api_key, api_secret
# 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.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure APIv4 key authorization
configuration = gate_api.Configuration(host="https://api.gateio.ws/api/v4",
                                       key=api_key,
                                       secret=api_secret)

api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.SpotApi(api_client)
status = 'status'  # str | List orders based on status
market = 'BTC_USDT'  # str | Currency pair (optional)
# account = 'account_example' # str | Trading account (optional)
limit = 100  # int | Maximum number of records returned in one list (optional) (default to 100)
offset = 0  # int | List offset, starting from 0 (optional) (default to 0)

try:
    # Retrieve running auto order list
    api_response = api_instance.list_spot_price_triggered_orders(
        status, market=market, account=account, limit=limit, offset=offset)
    print(api_response)
except GateApiException as ex:
from __future__ import print_function
import gate_api
from gate_api.rest import ApiException

configuration = gate_api.Configuration()
# APIV4
configuration.key = 'your gateio key'
configuration.secret = 'your gateio secret'
##########################################################获取账户信息################################################################
print("*" * 50 + "获取该账户的LTC信息" + 50 * "*")
# create an instance of the API class
api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration))
currency = 'LTC'  # str | Retrieved specified currency related data (optional)

try:
    # List spot accounts
    api_response = api_instance.list_spot_accounts(currency=currency)
    print(api_response)
except ApiException as e:
    print("Exception when calling SpotApi->list_spot_accounts: %s\n" % e)
print("*" * 50 + "获取该账户的USDT信息" + 50 * "*")
# create an instance of the API class
api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration))
currency = 'USDT'  # str | Retrieved specified currency related data (optional)

try:
    # List spot accounts
    api_response = api_instance.list_spot_accounts(currency=currency)
    print(api_response)
except ApiException as e:
    print("Exception when calling SpotApi->list_spot_accounts: %s\n" % e)