hirokisan / bybit

Bybit client library for Go

Home Page:https://pkg.go.dev/github.com/hirokisan/bybit/v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Timestamp errors

rsm778877 opened this issue · comments

Hi,

The exchange sometimes returns errors:

Error 10002, invalid request, please check your server timestamp or recv_window param. req_timestamp[1693378842140],server_timestamp[1693378847528],recv_window[5000]

How to fix this?

Thanks

@rsm778877

Thank you for your comment.

@Sagleft has added a way to handle this, so please check it out.
#134

@hirokisan will it work automatically or should I set some params/options?

You should be able to synchronize time differences by calling SyncServerTime.

ref:

bybit/client.go

Lines 419 to 430 in 0298136

func (c *Client) SyncServerTime() error {
r, err := c.NewTimeService().GetServerTime()
if err != nil {
return fmt.Errorf("get server time: %w", err)
}
if r.RetMsg != "OK" {
return fmt.Errorf("get server time: %s", r.RetMsg)
}
return c.updateSyncTimeDelta(r.Result.TimeNano, time.Now().UnixNano())
}

I will close it once because time has passed.