This repository is archived. For new websocket implementations, refer to gatews
gateio WebSocket-API API Document
gateio WebSocket-API
This repository is archived. For new websocket implementations, refer to gatews
gateio WebSocket-API API Document
Hi,
I am sending the following request through the API v4:
{
"time": "1626964798",
"channel": "spot.trades",
"event": "subscribe",
"payload": [
"LTC_USDT"
]
}
I get the following response:
{
"time": 1626965030,
"channel": "",
"event": "",
"error": {"code": 1, "message": "request payload does not follow json schema" },
"result": null
}
(please ignore timestamps, I may have pulled the message from a different try, but same message each time)
Any advice on what I am doing wrong?
nodejs调用报这个错Error: certificate has expired
您好,请问当前websocke服务除JavaScript和Python外连接外,都需要导入证书吗?如果是的话证书对不对外开放?
gate.wsGet(Math.round(Math.random()*1000),'kline.query', ["BTC_USDT", 1, 1516951219, 1800]);
这里start 1和end 1516951219表示什么?
猜测1516951219应该是unix time,单位是秒,1肯定不是unix时间,那是什么意思?
我如果要得到过去24小时的 1min类型的 kline数据,应该传什么参数?
What do start 1 and 1516951219 mean here ?
I guess 1516951219 should be unix time in seconds (not in milliseconds as is the usual case), but then what does 1 mean ?
Say If I want to get the 1min kline data in the past 24 hours, what start
and end
values should be used ?
Update:
我传的第一个参数传错了,用了毫秒,没有用秒
I found I used milliseconds in my own code, not seconds ... , but using 1 as the start time in the example is a little confusing, it is unlikely to mean getting all the kline data since 1970.
Correlation Id: 3988a7b111e742b99dcf853105295cb9
Timestamp: 2024-07-04T16:51:32.363Z
https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/resolve/main/model.safetensors.index.json?download=trueborder: 1px #30 solid;
border-radius: 4px;
height: 650px;
width: 450px;
{"label":"INVALID_SIGNATURE","message":"Signature mismatch"}\n"}
为什么总提示这个呀 api key sign 都是正确的
Hi, I am unable to recreate the same HMAC signature in python3. In python3 you need to pass it a bytes object since str is not supported anymore as an argument for hmac.
Python2 Example:
# -*- coding: utf-8 -*-
import hmac
import hashlib
import base64
def sign(secret, message):
msg_hash = hmac.new(secret, message, hashlib.sha512)
msg_hash = msg_hash.digest()
msg_hash = base64.b64encode(msg_hash)
return msg_hash
Python3 Example:
# -*- coding: utf-8 -*-
import hmac
import hashlib
import base64
def sign(secret, message):
message = message.encode('utf-8')
secret = secret.encode('utf-8')
msg_hash = hmac.new(secret, message, hashlib.sha256)
msg_hash = msg_hash.digest()
msg_hash = base64.b64encode(msg_hash)
return msg_hash
Now if i run
(sign('jafsdljkahsjhafjklsadlfak','1552960209216' ))
The results are different.
Python2:
lFXxSNxoV+wRS0v6sorrFwJGUGkGAUczqMWU869ABmMJwP1+17uqa0YjX8eBZif4kna7P3LAR+gkii/OMauQpg==
Python3:
b'+P5Zday6xpB60/RArWMZmExteHSl6zcz0Dc7NpfddlI='
新版 WebSocket SDK 会在近期展开,需要关注 SDK 更新的用户请订阅该 issue 。关闭 gateio/gateapi-python#41
New WebSocket SDK is planned in the near future. Subscribe to this issue if this relates to you.
websocket的usertrades是否支持margin cross_margin
Depth subscription version 3 : https://www.gate.io/docs/websocket/index.html?javascript#depth-subscription
When subscribing, 'depth.subscribe', ["ETH_USDT", 5, "0.0001"]
The first message comes with a value:
{ "method": "depth.update", "params": [ **_true_**, { asks: [Array], bids: [Array], **_id: 1736394129_** },
Аnd contains the complete specified,in this case "5" ORDERBOOK and id.
But subsequent messages with a value of false do not contain an id.
How can you know for sure that a message has not been lost without comparing the id?
websocket connection lost, retry to reconnect
error returned: code: 2, message: http get status code err, status : 400, url : http://127.0.0.1:8130/ws_auth, info : {"label":"REQUEST_EXPIRED","message":"gap between request Timestamp and server time exceeds 60"}
error returned: error returned: code: 2, message: http get status code err, status : 400, url : http://127.0.0.1:8130/ws_auth, info : {"label":"REQUEST_EXPIRED","message":"gap between request Timestamp and server time exceeds 60"}
code: 2, message: http get status code err, status : 400, url : http://127.0.0.1:8130/ws_auth, info : {"label":"REQUEST_EXPIRED","message":"gap between request Timestamp and server time exceeds 60"}
https://github.com/github/docs/blob/main/content%2Fcode-security%2Fcode-scanning%2Ftroubleshooting-code-scanning%2Funnecessary-step-found.md[rank1]: Traceback (most recent call last):
[rank1]: File "/home/zach/work/test.py", line 73, in
[rank1]: peft_trainer.train(
[rank1]: File "/home/zach/miniconda3/envs/accelerate/lib/python3.10/site-packages/transformers/trainer.py", line 1944, in train
[rank1]: return inner_training_loop(
[rank1]: File "/home/zach/work/accelerate/src/accelerate/utils/memory.py", line 144, in decorator
[rank1]: return function(batch_size, *args, **kwargs)
[rank1]: File "/home/zach/miniconda3/envs/accelerate/lib/python3.10/site-packages/transformers/trainer.py", line 2242, in _inner_training_loop
[rank1]: for step, inputs in enumerate(epoch_iterator):
[rank1]: File "/home/zach/work/accelerate/src/accelerate/data_loader.py", line 454, in iter
[rank1]: current_batch = next(dataloader_iter)
[rank1]: File "/home/zach/miniconda3/envs/accelerate/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 631, in next
[rank1]: data = self._next_data()
[rank1]: File "/home/zach/miniconda3/envs/accelerate/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 677, in _next_data
[rank1]: data = _utils.pin_memory.pin_memory(data, self._pin_memory_device)
[rank1]: File "/home/zach/miniconda3/envs/accelerate/lib/python3.10/site-packages/torch/utils/data/_utils/pin_memory.py", line 68, in pin_memory
[rank1]: clone.update({k: pin_memory(sample, device) for k, sample in data.items()})
[rank1]: File "/home/zach/miniconda3/envs/accelerate/lib/python3.10/site-packages/torch/utils/data/_utils/pin_memory.py", line 68, in
[rank1]: clone.update({k: pin_memory(sample, device) for k, sample in data.items()})
[rank1]: File "/home/zach/miniconda3/envs/accelerate/lib/python3.10/site-packages/torch/utils/data/_utils/pin_memory.py", line 58, in pin_memory
[rank1]: return data.pin_memory(device)
[rank1]: File "/home/zach/miniconda3/envs/accelerate/lib/python3.10/site-packages/torch/utils/_device.py", line 78, in torch_function
[rank1]: return func(*args, **kwargs)
[rank1]: RuntimeError: cannot pin 'torch.cuda.LongTensor' only dense CPU tensors can be pinned
官方文档这里只有limit - 限价单
https://github.com/huggingface/transformers/pull/31711from PIL import Image
import requests
import torch
from transformers import AutoProcessor, AutoModelForVision2Seq, AutoConfig
import re
repo = "kirp/kosmos2_5"
device = "cuda:0"
config = AutoConfig.from_pretrained(repo)
NAME = {
"f" : "flash_attention_2",
"s" : "sdpa",
"e" : "eager",
}
dtype = torch.float16
config._attn_implementation = NAME["s"]
config.vision_config._attn_implementation = NAME["s"]
config.text_config._attn_implementation = NAME["s"]
model = AutoModelForVision2Seq.from_pretrained(repo, device_map = device, torch_dtype=dtype, config=config)
processor = AutoProcessor.from_pretrained(repo)
url = "https://huggingface.co/kirp/kosmos2_5/resolve/main/receipt_00008.png"
image = Image.open(requests.get(url, stream=True).raw)
prompt = "" #
inputs = processor(text=prompt, images=image, return_tensors="pt")
height, width = inputs.pop("height"), inputs.pop("width")
raw_width, raw_height = image.size
scale_height = raw_height / height
scale_width = raw_width / width
inputs = {k: v.to(device) if v is not None else None for k, v in inputs.items()}
inputs["flattened_patches"] = inputs["flattened_patches"].to(dtype)
generated_ids = model.generate(
**inputs,
max_new_tokens=1024,
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
def postprocess(y, scale_height, scale_width):
y = y.replace(prompt, "")
if "" in prompt:
return y
pattern = r"<x_\d+><y_\d+><x_\d+><y_\d+>"
bboxs_raw = re.findall(pattern, y)
lines = re.split(pattern, y)[1:]
bboxs = [re.findall(r"\d+", i) for i in bboxs_raw]
bboxs = [[int(j) for j in i] for i in bboxs]
info = ""
for i in range(len(lines)):
box = bboxs[i]
x0, y0, x1, y1 = box
if not (x0 >= x1 or y0 >= y1):
x0 = int(x0 * scale_width)
y0 = int(y0 * scale_height)
x1 = int(x1 * scale_width)
y1 = int(y1 * scale_height)
info += f"{x0},{y0},{x1},{y0},{x1},{y1},{x0},{y1},{lines[i]}"
return info
output_text = postprocess(generated_text[0], scale_height, scale_width)
print(output_text)https://huggingface.co/kirp/kosmos2_5/resolve/main/receipt_00008.png.
Please help!!
I'm having trouble to trade with leverage on the BTC/USD futures via API (3Commas). The trade does happen but with only 1x leverage.
I'm trying to have 20x leverage on the BTC/USD via API (3Commas) on 50USD worth account.
I had initial inquiry on the live chat and the lady told me i'm from restricted country which I believe she is mistaken because i'm from South Korea, not North Korea. I reached out again for live support and then she told me that it cannot be addressed in live chat but asked me to submit the ticket. Then i submitted the ticket and got response that i should check here.. (very inefficient way to guide people.. )
Just for my purpose, I did try 2x leverage trade on the Web (not via API) manually, and i was able to trade with 2x leverage. So it seems like there is some API related issue..
please let me know how i could potentially solve this issue. thank you.
我跑的nodejs的例子程序.
server.sign方法返回报错:
{"error": {"code": 11, "message": "Invalid timestamp."}, "result": null, "id": 973}
key和secret用的我自己的. 请确认一下是否是bug或者是配置问题?
response:
id | Integer | orderid |
---|---|---|
market | String | market |
user | Integer | user id |
ctime | Float | ctime |
mtime | Float | mtime |
price | String | price |
amount | String | amount |
left | String | left |
dealFee | String | deal fee |
orderType | Integer | order type, 1: limit, 2: market |
type | Integer | type, 1: sell, 2: buy |
filledAmount | String | filled amount |
filledTotal | String | filled total |
这个mtime是什么时间,我猜是订单的修改时间,但是我在测试的时候,发现一个订单结束之后,这个时间和系统当前时间差的很大,有几十秒,也有的只有几百毫秒
We suggest using the new WebSocket v4 instead.
Originally posted by @revilwang in #19 (comment)
Hello. Tell me if there is a way to achieve time synchronization between the Api server, which subscribes to the Api via webcoket?
There is a request, ping-pong, which, on command, sends the time to my server and receives a response for some time (I assume the time of the server). And what can this give? You can simply measure the time from sending to receiving a request.
when i use demo codes python, nodejs for API 4.0 result:
{"error": {"code": 11, "message": "Authentication fail."}, "result": null, "id": 4041}
The algorithm sign params is wrong?
Code python:
def get_sign(secret_key, message):
h = (base64.b64encode(hmac.new(secret_key.encode('utf-8'), message.encode('utf-8'), hashlib.sha512).digest())).decode()
Code nodejs:
function getSign(str) {
return crypto.createHmac('sha512', SECRET).update(str).digest().toString('base64');
你好,我想通过 websocket 的 account 通道得到我现在的用户信息,希望包括,所有余额、可用余额、冻结等。但是,websocket 的 account 通道只返回两个有用信息,一个是 balance 一个是 change.
其中,balance 我认为这个数据返回的一直是总的所有余额。在 api 中其解释是 balance after changed,我理解为是比价变化之后的总余额。
而,change 我一直没有搞明白是什么意思?请告知我,这个属性代表什么意思,以及,我如何通过 websocket 获得 所有余额、可用余额、冻结等用户信息!谢谢!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.