예제 #1
0
        /// <summary>
        /// Refreshes the StoredOffset
        /// </summary>
        public void Refresh(ApiTime exchangetime)
        {
            if (exchangetime == null)
            {
                throw new ArgumentNullException(nameof(exchangetime));
            }

            this.StoredOffset = exchangetime.UnixTimestamp - DateTime.UtcNow.ToUnixTimestamp();
        }
예제 #2
0
        /// <summary>
        /// Returns the real time offset between the GDAX API web servers time and the clients local time in seconds.
        /// <para>To allow the client time to more closely match the GDAX API web servers time reducing the likelyhood of a "request timestamp expired" exception,</para>
        /// <para>use <see cref="StoredOffset"/> to get the stored offset and use <see cref="Refresh"/> to refresh the stored offset.</para>
        /// <para>Note that the real vs stored offset can change over time, periodically check that the real vs stored value does not exceed
        /// ±30 seconds and refresh when it does, or you will start to recieve "request timestamp expired" exceptions.</para>
        /// </summary>
        public double RealOffset(ApiTime exchangetime)
        {
            if (exchangetime == null)
            {
                throw new ArgumentNullException(nameof(exchangetime));
            }

            return(exchangetime.UnixTimestamp - DateTime.UtcNow.ToUnixTimestamp());
        }