Code Monkey home page Code Monkey logo

gateapi-python's People

Contributors

gateio avatar revilwang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gateapi-python's Issues

Scientific notation price

Hello, I have encountered a weird thing. Why can't I pass price as scientific notation? It's not a case for all other exchanges, I get an "Invalid requests parameter 'price' value: 6.521e-05" (here is an example for HSC/USDT) error, how is it possible that endpoint doesn't accept scientific notation? Making it a string doesn't help. How can I solve that?

不能创建永续合约订单,提示: INVALID_PROTOCOL / Can't Create FuturesOrder

代码是这样的:
Code:

   print(symbol)
    futures_order = gate_api.FuturesOrder(contract=symbol, size=-1 * quantity, price=price,reduce_only=False,tif="gtc")  # FuturesOrder

    try:

        # Create a futures order

        api_response = self.api_instance.create_futures_order(futures_order)
        print(api_response)
        return api_response
    except ApiException as e:
        print("Exception when calling FuturesApi->create_futures_order: %s\n" % e)
        raise e

输出是这样的:
Output:

BTC_USD

Exception when calling FuturesApi->create_futures_order: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Sun, 26 May 2019 06:10:07 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty/1.13.6.1'})
HTTP response body: {"label":"INVALID_PROTOCOL","detail":"invalid argument: #3"}

Gate api exception, label: INVALID_SIGNATURE, message: Signature mismatch

请问哪里有问题会导致签名不匹配, key和secret分别改成1和2了。

import gate_api
from gate_api.exceptions import ApiException, GateApiException

HOST = "https://api.gateio.ws/api/v4"
API_KEY = "1"
API_SECRET = "2"

# 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=HOST,
    key=API_KEY,
    secret=API_SECRET,
)

api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_withdrawal = gate_api.WithdrawalApi(api_client)

try:
    # List all futures contracts
    api_response = api_withdrawal.withdraw(
        ledger_record='{"currency":"ttt","address":"tttt","amount":"10.1","memo":""}'
    )
    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 DeliveryApi->list_delivery_contracts: %s\n" % e)

futures contracts websocket signature method

合约交易获取交易的订单,需要权限部分,签名是如何实现的,SIGN怎么生成的。websocket方式,不是rest方式。
from websocket import create_connection
ws = create_connection("wss://fx-ws-testnet.gateio.ws/v4/ws")
ws.send('{
"time" : 123456,
"channel" : "futures.orders",
"event": "subscribe",
"payload" : ["20011", "BTC_USD"],
"auth": {
"method": "api_key",
"KEY":"xxxx",
"SIGN": "xxxx"
}}')

合约API收到401错误 Missing required header: Timestamp

之前已经调试通过的Python代码,最近执行遇到API报错:
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Date': 'Sat, 11 Apr 2020 16:17:12 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"}
已经更新Python版本的API代码4.11版本,咨询一下如何解决。

杠杆交易撤单 'Cancel order too fast, please wait 1 min and try again.'

我在币币交易15个品种上做市挂单,杠杆交易7个品种上做市挂单
挂单撤单的策略和频率应该是一样差不多的
然后 币币交易的所有品种 撤单都没有超频率限制,但是杠杆交易的品种 昨晚开始 一直返回{'label': 'METHOD_NOT_ALLOWED', 'message': 'Cancel order too fast, please wait 1 min and try again.'}

获取个人已经成交的订单

获取个人已经成交的订单(现货,合约,期货),能不能接口加一个字段text也跟着返回?(就是下单时候的字段text)

撤单频率又被限制了

你好!
我目前在gate的七个交易对上做市(日交易量达到60btc了,还能往上加)做到昨天都很顺畅,但是今天11:49撤单又被限频了。。
我的uid是2541076
我的七个程序,每个程序每分钟调用撤单接口(参数有account=margin)撤单10~30次。今天做到11:49之前都正常,11:49开始返回{'label': 'METHOD_NOT_ALLOWED', 'message': 'Cancel order too fast, please wait 1 min and try again.'},此后就一直这个状态。
然后我关掉所有程序,等待了十分钟,重启其中一个程序后,第一次撤单 依然返回{'message': 'Cancel order too fast, please wait 1 min and try again.', 'label': 'METHOD_NOT_ALLOWED'}

超时time怎么设置

环境:python
问题:由于默认timeout时间太长 导致拉不到数据容易卡死,怎么设置timeout在python api里

How to place a market order?

This question is not about the Python API per se but the REST API in general.

Following the docs at https://www.gate.io/docs/apiv4/en/index.html#create-an-order, only "type": "limit" is a valid value. Can it also be used to place a market order? Intuitively, for a market order, I would set "time_in_force": "ioc", but I don't know what to set the price.

I could query the orderbook for current prices and pick a price that would immediately fill, but perhaps there is an easier way?

Full Futures Position Close History

Hello,

Is there any way to get a full paginated list of closed position history? I am using futures list position close history method however it has a limit of 100 entries, I couldn't find any kind of pagination.

Regards

b'{"label":"INVALID_SIGNATURE","message":"Signature mismatch"}\n'

def gen_sign(method, url, query_string=None, payload_string=None):
    key = 'xxxxx'  # api_key
    secret = 'xxxxx'  # api_secret

    current_time = time.time()
    m = hashlib.sha512()
    if payload_string is not None:
        m.update(payload_string.encode('utf-8'))
    hashed_payload = m.hexdigest()
    s = '%s\n%s\n%s\n%s\n%s' % (method, url, query_string or "", hashed_payload, current_time)
    sign = hmac.new(secret.encode('utf-8'), s.encode('utf-8'), hashlib.sha512).hexdigest()
    return {'KEY': key, 'Timestamp': str(current_time), 'SIGN': sign}


if __name__ == "__main__":
    host = "https://api.gateio.ws"
    prefix = "/api/v4"
    common_headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

    url = '/futures/accounts'
    sign_headers = gen_sign('GET', prefix + url, "", None)
    sign_headers.update(common_headers)
    print('signature headers: %s' % sign_headers)
    res = requests.post(host + prefix + url, headers=sign_headers, data=None)
    print(res.status_code)
    print(res.content)

POST /spot/orders 中的type参数

如题。api说明中,仅提供了limit一个说明,没有别的type值了吗?
如我想以固定价格买入而非当前价交易,该如何输入?

auth faild , auth data : \u0026{{87260}

订阅futures.orders和futures.balances的websocket,都报如下错误,不知道什么意思
{"time":1570513208,"channel":"futures.orders","event":"subscribe","error":{"code":2,"message":"auth faild , auth data : \u0026{{87260}}"},"result":{"status":"failed"}}

深度数据咨询

[{'p': '3.097', 's': 0, 'c': 'EOS_USD', 'id': 24679122}, {'p': '3.078', 's': 981, 'c': 'EOS_USD', 'id': 24679123}]
[{'p': '3.082', 's': 0, 'c': 'EOS_USD', 'id': 24679264}, {'p': '3.088', 's': 516, 'c': 'EOS_USD', 'id': 24679265}]
[{'p': '3.099', 's': -78, 'c': 'EOS_USD', 'id': 24679124}, {'p': '3.11', 's': -779, 'c': 'EOS_USD', 'id': 24679125}]
1、深度更新的时候,0代表是卖盘还是买盘
2、更新的数据如何对于第几档位上

请教api字段含义

1、change_percentage/mark_price/index_price 代表什么意思
2、资金费率剩余时间怎么获取

撤单频率有限制吗

撤单频率有限制嘛?{'label': 'METHOD_NOT_ALLOWED', 'message': 'Cancel order too fast, please wait 1 min and try again.'}是什么触发的?

Rebasing info

Hello! Is there any part where API endpoints inform about currency "rebasing"? (whatever it is)? trade_status in list_currency_pairs() gives "tradable" status even tho I wouldn't call it tradable as not all actions can be taken on the pair then.

内存溢出问题!

我用concurrent.futures模块使用多线程,内存就一直增加,然后ccxt改写脚本,内存没有问题!用objgraph和memory_profiler模块找脚本内存增加的原因!脚本所有的变量都没有问题!哎。。。。

合约函数有问题!

官方应该加了双向合约,导致有些函数有问题,目前发现update_position_leverage(settle, contract, leverage) # 调整合约杠杆倍数,这个函数有问题,应该是少了参数了!

how to use this api to trade with my margin funds

The MarginApi don't provide the "create order" method, is there any way i can use to trade on margin.

I try this:

  1. create an order
    order=gate_api.Order(currency_pair='ATOM_USDT',price=4.82,account='margin',amount=1,side='sell')
    spot = gate_api.SpotApi(gate_api.ApiClient(configuration))

  2. then passing the order to spot.create_order
    api_response=spot.create_order(order=order)

This method raises exception below:
ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Fri, 03 May 2019 13:25:20 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '61', 'Connection': 'keep-alive', 'Server': 'openresty/1.13.6.1', 'X-Request-Id': '[1879f505]'})
HTTP response body: {"label":"BALANCE_NOT_ENOUGH","message":"balance not enough"}

'/api2/1/coininfo' 获取USDT_ETH, USDT_TRX可提币状态不对

您好,通过'/api2/1/coininfo'这个api path获取USDT_ETH和USDT_TRX的可提币状态不对,api获取到的是不可提币状态,实际上是可以提币的,请检查一下,谢谢。

{
    "USDT_TRX": {
        "delisted": 0,
        "withdraw_disabled": 1,
        "withdraw_delayed": 0,
        "deposit_disabled": 0,
        "trade_disabled": 0
    },
    "USDT_ETH": {
        "delisted": 0,
        "withdraw_disabled": 1,
        "withdraw_delayed": 0,
        "deposit_disabled": 0,
        "trade_disabled": 1
    }
}

websocket的接口库能不能重写一下啊!

3大所的websocket接口库都有!你只要把火币和币安的库看一下!然后套一下就可以发布了吧!比现在这个12个月都不更新的好多了!期待。。。。

[Question] How to list main spot account balances?

From the API, I found the following method for listing sub-account balances:

def list_sub_account_balances(self, **kwargs): # noqa: E501
. I am not using sub-accounts and it returns an empty list for me.

I also tried the websocket API described here: https://www.gate.io/docs/apiv4/ws/index.html#client-subscription-9. This one only seems to deliver updates to balances, but cannot provide current snapshot of all balances.

How to list balances for main spot account? Should I use v2 REST API instead?

永续合约Rest返回结果json后面多了'\n'

你好,Rest下单或者cancel的时候,返回的json数据后面多了一个'\n',在用其它语言(非python,例如Rust decode from bytes)的时候会失败,麻烦把这个\n去掉

{ "id": 13045871072, "contract": "ALGO_USDT", "mkfr": "-0.0002", "tkfr": "0.0003", "tif": "poc", "is_reduce_only": false, "create_time": 1614832119.068, "price": "1.175", "size": 35, "refr": "0", "left": 35, "text": "t-474367393834", "fill_price": "0", "user": 3114850, "status": "open", "is_liq": false, "refu": 0, "is_close": false, "iceberg": 0 }\n

个别杠杆账户出现无法下单的情况

你好 我的uid是2541076 我在七个币种上做杠杆下单,六个币种完全正常,但是xrp币种有个问题。

xrp杠杆账户余额是一万个xrp,网页版杠杆页面可以挂一万xrp的卖单并撤掉,但是通过api挂3000个xrp的卖单,显示 {'label': 'MARGIN_BALANCE_NOT_ENOUGH', 'message': 'No margin account or margin balance is not enough'}
这个是个别币种的现象,不是普遍的。

关于k线数据获取api

/spot/candlesticks
这个api如果设置1d,则返回的开盘价是24小时前开盘价,还是上午8点(当日)开盘价?
是否有时区区分?

Transfer api不可用

您好,我参照github上gateio-python的api进行spot到margin的划转操作,提示404 not found
https://github.com/gateio/gateapi-python/blob/937548602284c1a7a0192b1eef0e882520b7441c/gate_api/models/transfer.py

参数和请求:
post /api/v4/wallet/transfers params={'currency': 'USDT', 'currency_pair': 'ETH_USDT', 'amount': '51', '_from': 'spot', 'to': 'margin’}

响应:
Get a error on http POST request for url https://api.gateio.ws/api/v4/wallet/transfers, HTTP 404: Not Found b'{"label":"NOT_FOUND"}\n’

请问是哪里设置的不对吗,还是这个api没有上线?

关于sdk的问题

想问一下。
Gate API v4 v4.11.0中提供的python sdk 和 网页版API是一样的吗?
api版本更新,网页版的和sdk都是同步更新吗?
访问端口,反馈速度等都是没差别的吗。

请求延迟是多长时间?

我看了一下rest模块下面的request函数的_request_timeout参数的None!是这个_request_timeout参数设置post和get等等返回的延迟时间吗?我写了个脚本,然后直接死了哪里,try也没有错误出来,肯定是没有超时设置时间吗?

撤单被限制

你好!我的uid是2541076

交易了七天 交易量做到了1846.80694 BTC 103417495.03 CNY

我还是七个品种 杠杆账户交易撤单接口撤单,每分钟其实加起来不会超过300次的。

从今天04:50左右开始,又一直显示{'message': 'Cancel order too fast, please wait 1 min and try again.', 'label': 'METHOD_NOT_ALLOWED'

请问能不能解决一下...行情这么好 有点郁闷... 目前我停掉所有程序后五六分钟 重启了下 还是返回Cancel order too fast

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.