Merge pull request #247 from Tindtily/master
Add syncTimeBeforePrivateRequests option
This commit is contained in:
@@ -114,6 +114,8 @@ export default abstract class BaseRestClient {
|
|||||||
enable_time_sync: false,
|
enable_time_sync: false,
|
||||||
/** How often to sync time drift with bybit servers (if time sync is enabled) */
|
/** How often to sync time drift with bybit servers (if time sync is enabled) */
|
||||||
sync_interval_ms: 3600000,
|
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. */
|
/** Request parameter values are now URI encoded by default during signing. Set to false to override this behaviour. */
|
||||||
encodeSerialisedValues: true,
|
encodeSerialisedValues: true,
|
||||||
...restOptions,
|
...restOptions,
|
||||||
@@ -204,6 +206,10 @@ export default abstract class BaseRestClient {
|
|||||||
await this.syncTime();
|
await this.syncTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.options.syncTimeBeforePrivateRequests) {
|
||||||
|
this.timeOffset = await this.fetchTimeOffset();
|
||||||
|
}
|
||||||
|
|
||||||
return this.signRequest(params || {}, method, signMethod);
|
return this.signRequest(params || {}, method, signMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ export interface RestClientOptions {
|
|||||||
/** How often to sync time drift with bybit servers */
|
/** How often to sync time drift with bybit servers */
|
||||||
sync_interval_ms?: number | string;
|
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 */
|
/** Default: false. If true, we'll throw errors if any params are undefined */
|
||||||
strict_param_validation?: boolean;
|
strict_param_validation?: boolean;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user