Add syncTimeBeforePrivateRequest option

Add syncTimeBeforePrivateRequest option to determines whether to perform time synchronization before sending private requests
This commit is contained in:
Morphling
2023-04-18 04:37:11 +08:00
parent d9e536e7e1
commit 6b1863c289
2 changed files with 9 additions and 0 deletions

View File

@@ -113,6 +113,8 @@ export default abstract class BaseRestClient {
enable_time_sync: false,
/** How often to sync time drift with bybit servers (if time sync is enabled) */
sync_interval_ms: 3600000,
/** Determines whether to perform time synchronization before sending private requests */
syncTimeBeforePrivateRequests: false,
/** Request parameter values are now URI encoded by default during signing. Set to false to override this behaviour. */
encodeSerialisedValues: true,
...restOptions,
@@ -203,6 +205,10 @@ export default abstract class BaseRestClient {
await this.syncTime();
}
if (this.options.syncTimeBeforePrivateRequests) {
this.timeOffset = await this.fetchTimeOffset();
}
return this.signRequest(params || {}, method, signMethod);
}

View File

@@ -22,6 +22,9 @@ export interface RestClientOptions {
/** How often to sync time drift with bybit servers */
sync_interval_ms?: number | string;
/** Determines whether to perform time synchronization before sending private requests */
syncTimeBeforePrivateRequests?: false;
/** Default: false. If true, we'll throw errors if any params are undefined */
strict_param_validation?: boolean;