Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BybitClient.CopyTradingApi.Trading.GetPositionsAsync() invalid request #66

Open
ThaiCat opened this issue Oct 11, 2022 · 2 comments
Open

Comments

@ThaiCat
Copy link

ThaiCat commented Oct 11, 2022

If I call BybitClient.UsdPerpetualApi.Account.GetPositionAsync(Symbol)
and after that I call
BybitClient.CopyTradingApi.Trading.GetPositionsAsync()
it returns the following error:
{10002: invalid request, please check your server timestamp or recv_window param }

If I first call BybitClient.CopyTradingApi.Trading.GetPositionsAsync() and then call BybitClient.UsdPerpetualApi.Account.GetPositionAsync(Symbol) it returns similar error which looks like the following:
{10002: invalid request, please check your timestamp and recv_window param. req_timestamp: 1665531628720 server_timestamp: 1665531627702 recv_window: 5000 }

@JKorf
Copy link
Owner

JKorf commented Oct 28, 2022

Hi, I've fixed some things in the timestamping, could you try again with the latest version?

@ThaiCat
Copy link
Author

ThaiCat commented Nov 1, 2022

behaviour is more consistent now, but if my local time is 1 second outdated, this does not work.

to test it i used following code


        [StructLayout(LayoutKind.Sequential)]
        public struct SYSTEMTIME
        {
            public short wYear;
            public short wMonth;
            public short wDayOfWeek;
            public short wDay;
            public short wHour;
            public short wMinute;
            public short wSecond;
            public short wMilliseconds;
        }
        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern bool SetSystemTime(ref SYSTEMTIME st);

and before the api call

            SYSTEMTIME st = new SYSTEMTIME();
            st.wYear = (short) t.Year;
            st.wMonth = (short)t.Month ;
            st.wDay = (short)t.Day;
            st.wHour = (short)(t.Hour-0);
            st.wMinute = (short)(t.Minute-0);
            st.wSecond = (short)(t.Second + 1);

            SetSystemTime(ref st);

if my local time differs from timeserver time by more than 1 second, api calls return an error.
I probably dont get it, but shouldn't the 5000 ms recv_window let the api calls work up to 5 seconds time desync in at least one direction (assuming network delays are way below 1s)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants