예제 #1
0
    async def transfer_asset(self, currency, amount, from_field, from_pair,
                             to_field, to_pair):
        symbol = currency.value.upper()
        from_field_text = self.__std_field_to_ex_text_dict__[from_field]
        from_pair_text = from_pair.to_underscore_text()
        to_field_text = self.__std_field_to_ex_text_dict__[to_field]
        to_pair_text = to_pair.to_underscore_text()
        kwargs = {
            'currency': symbol,
            '_from': from_field_text,
            'to': to_field_text,
            'amount': str(amount)
        }
        if from_field == ExchangeField.MARGIN:
            kwargs['currency_pair'] = from_pair_text
        elif to_field == ExchangeField.MARGIN:
            kwargs['currency_pair'] = to_pair_text
        if currency == MarketCurrency.USDT:
            kwargs['settle'] = 'usdt'
        elif currency == MarketCurrency.BTC:
            kwargs['settle'] = 'btc'

        self.logger.info(f'kwargs: {kwargs}')

        wallet_rest = gate_api.WalletApi(
            gate_api.ApiClient(configuration=self.conf))
        transfer = gate_api.Transfer(**kwargs)
        response = await asyncio.get_event_loop().run_in_executor(
            None, wallet_rest.transfer, transfer)
        self.logger.info(f'response: {response}')
예제 #2
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}")
예제 #3
0
파일: conf.py 프로젝트: sz982005/btcgate
        mailserver = 'smtp.qq.com'
        port = '465'
        sub = 'Gateio Surveil'

        try:
            msg = MIMEMultipart('related')
            msg['From'] = formataddr(["sender", sender])  # �����������dzơ������������˺�
            msg['To'] = formataddr(["receiver", receive])  # �ռ��������dzơ��ռ��������˺�
            msg['Subject'] = sub
            body = """
            <b>This is GateIO items:</b>
            <div>{e_html}</div>
            """.format(e_html = e_html)
            text = MIMEText(body, 'html', 'utf-8')
            msg.attach(text)
            smtpobj=smtplib.SMTP_SSL(mailserver,465) #��������б��ط�����������localhost ,Ĭ�϶˿ڣ���,��Ѷ�ģ��˿�465��587��
            smtpobj.set_debuglevel(1)
            smtpobj.login(sender,passwd)#��½QQ���������
            smtpobj.sendmail(sender, receive, msg.as_string())  # �����������˺š��ռ��������˺š������ʼ�
            smtpobj.quit()
            print('send mail success')
        except Exception as e:
            print(e)
		

forward_configuration = gate_api.Forward_Configuration()
backward_configuration = gate_api.Backward_Configuration()
forward_api_instance = gate_api.FuturesApi(gate_api.ApiClient(forward_configuration))
backward_api_instance = gate_api.FuturesApi(gate_api.ApiClient(backward_configuration))

예제 #4
0
                                      sender])  # �����������dzơ������������˺�
            msg['To'] = formataddr(["receiver",
                                    receive])  # �ռ��������dzơ��ռ��������˺�
            msg['Subject'] = sub
            body = """
            <b>This is GateIO items:</b>
            <div>{e_html}</div>
            """.format(e_html=e_html)
            text = MIMEText(body, 'html', 'utf-8')
            msg.attach(text)
            smtpobj = smtplib.SMTP_SSL(
                mailserver, 465
            )  #��������б��ط�����������localhost ,Ĭ�϶˿ڣ���,��Ѷ�ģ��˿�465��587��
            smtpobj.set_debuglevel(1)
            smtpobj.login(sender, passwd)  #��½QQ���������
            smtpobj.sendmail(
                sender, receive,
                msg.as_string())  # �����������˺š��ռ��������˺š������ʼ�
            smtpobj.quit()
            print('send mail success')
        except Exception as e:
            print(e)


forward_configuration = gate_api.Forward_Configuration()
backward_configuration = gate_api.Backward_Configuration()
forward_api_instance = gate_api.FuturesApi(
    gate_api.ApiClient(forward_configuration))
backward_api_instance = gate_api.FuturesApi(
    gate_api.ApiClient(backward_configuration))
예제 #5
0
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)