Code Monkey home page Code Monkey logo

gateapi-go's People

Contributors

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

gateapi-go's Issues

Cannot install package

Starting in Go 1.16, installing executables with go get is deprecated. go install may be used instead..
In official api website: https://github.com/gateio/gateapi-go , to get the package the command is:
go get github.com/gateio/gateapi-go/v6
and it does not work anymore and is needed to use go install , but I get error: is not a main package, after all week of researching I still cannot get to an answer, how to install the package.
image

I reinstalled to older version of Go 1.15, where are no major changes, but using official SDK it is still does not work, I used version v5 of package and it did download but was not added to mod.
image

Please help me solve the issue.

websoket是不是无法进行交易

看websocket的文档发现 只能检测币价 订单状态,余额等的变化。没法进行订单操作。是不是说明websocket无法进行下单操作?

client.MarginApi.ListLoans无法查询抵押借币订单

使用v4的api /margin/loans client.MarginApi.ListLoans查询借入借出订单
如果传side=lend, status=finished可以正常查询借出订单;
如果传side=borrow,status=open/loaned/finished都返回空,实际有若干个抵押借币订单。

有没有回调接口?

比如 下单之后,全部成交则向对应的请求方发通知,类似于微信,支付宝的回调接口

Page order is incorrect for public order (GET /spot/trades) request in v6.22.3

First of all - thank you @revilwang for adding support to requesting orders by time range in v6.22.3. It was a tricky task getting the correct ID of the old trade before.

So the problem is that when I make such a request with "from" and "to" and "page" I get pagination inverted.
For example if from Date A to Date B there were 500 trades then I expect to get trades 1-100 with "page" = 1 , then 101-200 with 'page' = 2 etc.
But I am getting trades 401-500 with "page" = 1 then 301-400 with 'page' = 2 , etc. So the pagination order is inverted. And its impossible to get the first trades right away because you have to know the maximum number of pages (since the order is inverted).
P.S. And if I don't send the 'page' parameter at all I get the last 100 trades in that time interval.

I hope my explanation makes sense.

杠杆账户利息

杠杆账户列表 (GET /margin/accounts). 接口怎么不返回借币对应未还的利息

Futures order amount

I didn't fully understand futures order. For example, I will buy $5 dogecoin. I couldn't understand how to enter 5 dollars into the API. Can you help me? I think I need to set this $5 with another api request. But how and where do I do it?

By looking at the process on the web, I enter size as 1 and price as 0. In this case, it tries to do the same thing I did last time on the web.

为什么撤销后的订单查询不到

下单之后会产生订单id,但是在该订单完成量为0的条件下撤销订单,再根据这个订单id查询该订单就提示label: ORDER_NOT_FOUND, message: Order with ID 12345678901 not found

怎么用NGINX搭建websocket代理

因gateio 服务器在国外,无法直接访问,现在需要将http接口请求改为websocket请求,请问怎么用nginx搭建websocket的代理?

gateio-api failure

I have an API connection exception when using official gateio-api. can you help me solve this problem

I can be sure that my Key and Secret are correct, but the connection is abnormal.

`2022-07-19T14:58:45.614+0800 info util/logger.go:122 log format is success.
2022-07-19T14:59:06.713+0800 error bitcoin/main.go:38 Get "https://api.gateio.ws/api/v4/delivery/usdt/contracts": dial tcp 65.49.68.152:443: connectex: A connection attem
pt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Process finished with exit code 0
`

指定列表行情信息获取

如果给可选参数传入nil,则会显示所有的行情,但是我想指定多个,如何做到的?我尝试了,目前貌似只能做一个?

result, _, err = client.SpotApi.ListTickers(ctx, &gateapi.ListTickersOpts{CurrencyPair: optional.NewString("btc_usdt")})

签名方法错误导致签名校验不通过

client.go第270行:
msg := fmt.Sprintf("%s\n%s\n%s\n%s\n%s", method, url, url.RawPath, hashedPayload, t)
会导致签名校验不通过
应改为:
msg := fmt.Sprintf("%s\n%s\n%s\n%s\n%s", method, url.Path, url.RawQuery, hashedPayload, t)

problem with structured-products in the API

Hello,

The API call "GET /wallet/total_balance" does not show the structured-products balance. This is what I get when I call it:

{Total:
  {Amount:1234 Currency:USDT}        
           Details:map[             
              cbbc:{Amount:0 Currency:USDT}             
              cross_margin:{Amount:0 Currency:USDT}             
              delivery:{Amount:0 Currency:USDT}             
              finance:{Amount:1234 Currency:USDT}             
              futures:{Amount:5 Currency:USDT}             
              margin:{Amount:0 Currency:USDT}             
              quant:{Amount:0 Currency:USDT}             
              spot:{Amount:1234 Currency:USDT}        
         ]
}

Where is the spructured-products balance?

cannot set futures order to short side

I just want to use "client.FuturesApi.CreateFuturesOrder" to create short side orders, however ,it is long position still,i set FuturesOrder.IsClose = true.

GetTotalBalanceOpts

I encountered a problem in the development process. Can you help me solve it,
As for the non essential parameter, how is it assigned,
For example:

"currency" parameter in "GetTotalBalance" module,
I set the "currency" parameter to, but I don't know how to set it,

The document indicates that GetTotalBalanceOpts struct can be used.

Can you provide an example?

Withdrawn Fee

How can i retrieve the withdrawn fee for some coin?

APIv4 transaction and position reporting issue: SHIB5L_USDT/SHIB5S_USDT

Hi,
I need help with a transaction and position reporting problem. I set up an APIv4 feed to pull transactions into Cointracker but transactions for SHIB5L_USDT and SHIB5S_USDT pairs in December 2021 are not showing up in the APIv4 feed. Further, they don't show up as current holdings even though they are currently held. Other holdings do show up accurately in Cointracker after using the APIv4 to sync. The SHIIB5L_USDT and SHIB5S_USDT first started trading on December 8, 2021.

Please help resolve.
Thanks!

cant get order by client id

Salutations.

I've created two orders for tests

orderId : 373656130585 with text: t-12345679 (2023-07-27 18:32:37)
orderId : 373654658195 with text: t-12345678 (2023-07-27 18:28:51)

Your documentation says

order_id: Order ID returned, or user custom ID(i.e., text field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted.

I've tried to get order just after it finished, after 5 minutes, after 10 minutes...

but I always got error

label: CLIENT_ID_NOT_FOUND, message: Order with client ID t-12345678 not found

To build fault tolerance system as much as possible we need to find orders by custom client ID.

{"label":"INVALID_SIGNATURE","message":"Signature mismatch"}

你好,签名不匹配
源码:

func (gate *GateioTrade) gen_sign(body *bytes.Buffer, path, method string) {
h := sha512.New()
if body != nil {
h.Write(body.Bytes())
}
hashedPayload := hex.EncodeToString(h.Sum(nil))

t := strconv.FormatInt(time.Now().Unix(), 10)
rawQuery, Path, err := gate.requestUrl(path)
if err != nil {
	msg := fmt.Sprintf("%s\n%s\n%s\n%s\n%s", method, Path, rawQuery, hashedPayload, t)
	mac := hmac.New(sha512.New, []byte(gate.APISecret))
	mac.Write([]byte(msg))
	sign := hex.EncodeToString(mac.Sum(nil))
	headerParams := make(map[string]string)
	headerParams["KEY"] = gate.APIKey
	headerParams["SIGN"] = sign
	headerParams["Timestamp"] = t
}

}

FutruesInitialOrder missing setting

image
image
missing AutoSize why?
I cleared the mod cache and re-fetched the dependencies, but the issue persists. The local package name is github.com/gateio/gateapi-go/v5.

借入或借出

借入或借出接口:POST /margin/loans
1、参数rate[贷款利率]在借入的情况下是必须要设置的吗?怎么计算?
2、参数amount[贷款额度]该怎么计算呢,借币数量*最新市价?
3、参数days[贷款天数]在借入的情况下是必须要设置的吗?怎么计算?

Unconsistency between /spot/currencies and wallet/currency_chains

Hello,

I am allowing myself to add this issue. I posted it on Telegram but most of the messages are in chinese, which led my message to be unnoticed. I know it is not the adequate place for it, sorry for this.

I noticed an inconsistency on those two endpoints:
https://api.gateio.ws/api/v4/spot/currencies
https://api.gateio.ws/api/v4/wallet/currency_chains?currency=USDT
On the first link we can see that USDT also support the BNB network, while on the second it is not the case.
Going on gate.io and trying to withdraw USDT, we can see that, indeed, we cannot withdraw through the BNB chain.
Is there something that I am missing or is it really a mistake?
Which one would you recommend using? Is it safe to withdraw on USDT_BNB, knowing that it is not listed by the wallet/currency_chains endpoint?

Thank you in advance.

请求经常超时

目前做的账户轮询测试,超时的几率太大了,结果返回
https://api.gateio.ws/api/v4/spot/accounts": net/http: TLS handshake timeout

双向持仓模式下 获取合约单个仓位信息报错

报错信息:
"json: cannot unmarshal array into Go value of type gateapi.Position"
代码:

func (base *GateService) FuturesPosition(currencyPair string) (gateapi.Position, error) {
	client := gateapi.NewAPIClient(gateapi.NewConfiguration())
	ctx := context.WithValue(context.Background(),
		gateapi.ContextGateAPIV4,
		gateapi.GateAPIV4{
			Key:    base.Config.ApiKey,
			Secret: base.Config.ApiSecret,
		},
	)
	settle := "usdt" // string - Settle currency
	// currencyPair = ""

	result, _, err := client.FuturesApi.GetPosition(ctx, settle, currencyPair)
	if err != nil {
		if e, ok := err.(gateapi.GateAPIError); ok {
			return result, errors.New(e.Message)
		} else {
			return result, err
		}
	}

	return result, nil
}

合约:ARB_USDT

ListMyTrades return empty data

I call list my trades api with parameter order and no page and limit,

the api return following data

{
    "message": ""
}

and http code is 404. status is "404 not found"

but, when I query with shell with the following code. I can get correct data:

the key secret and order_id all correct

can someone tell me why?

key="xxxxx"
secret="xxxx"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/spot/my_trades"
query_param="currency_pair=BTC_USDT&order_id=ORDER_ID"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

no matching versions for query "upgrade"

Hello ✋
I ran the following command:

go get github.com/gateio/gateapi-go

And I got the following output :

go get github.com/gateio/gateapi-go: no matching versions for query "upgrade"

And I looked at the go.mod file and it had the following contents:

...
go 1.12
...

Finally, I checked the current version, which you can see below:

go1.16.5

Please update this project ❗

Test Mode does not work consistently with live mode

consider the following:

type GateIO struct {
	api *gateapi.APIClient
}

func NewGateIO(testMode bool) *GateIO {
	cfg := gateapi.NewConfiguration()

	client := gateapi.NewAPIClient(cfg)
	if testMode {
		log.Println("running in test mode")
		client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
	}

	return &GateIO{api: client}
}

and

func (g *GateIO) CheckSupport(ctx context.Context, coin string) (bool, error) {
	cur, _, err := g.api.SpotApi.GetCurrency(ctx, coin)
	if err != nil {
		return false, fmt.Errorf("failed to check support for currency: %w", err)
	}

	return !cur.TradeDisabled, nil
}

Usage:


ctx := context.Background()

	gate := exchange.NewGateIO(false)

	supported, err := gate.CheckSupport(ctx, "DOGE")
	if err != nil {
		log.Fatal(err)
	}

	log.Println("supported:", supported)

prints out supported: true

Now I will turn on test mode and run the same code:

ctx := context.Background()

	gate := exchange.NewGateIO(true)

	supported, err := gate.CheckSupport(ctx, "DOGE")
	if err != nil {
		log.Fatal(err)
	}

	log.Println("supported:", supported)

I receive:

failed to check support for currency: label: MISSING_REQUIRED_HEADER, message: Missing required header: Timestamp

I would expect the test mode to be looser than the Live API,but it seems it is more restrictive.

API not working

Hi,

I tried to use my API with different tools (Atani, Koinly) but it doesn't work.
I took the API from www.gate.ac because www.gate.io is not accessible anymore in Italy.
Can you help me please?
Thank you

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.