v3.3.9: fix copy trading close order endpoint. add ws log for topic sub request. add example for rest copy closing.

This commit is contained in:
tiagosiebler
2023-01-07 12:05:32 +00:00
parent dbdaa6a865
commit 48e62402b8
4 changed files with 37 additions and 5 deletions

View File

@@ -0,0 +1,25 @@
import { CopyTradingClient } from '../src/index';
// or
// import { CopyTradingClient } from 'bybit-api';
const key = process.env.API_KEY_COM;
const secret = process.env.API_SECRET_COM;
const client = new CopyTradingClient({
key,
secret,
strict_param_validation: true,
});
(async () => {
try {
const res = await client.closeOrder({
symbol: 'BTCUSDT',
parentOrderId: '419190fe-016c-469a-810e-936bef2f1234',
});
console.log('res:', res);
} catch (e) {
console.error('request failed: ', e);
}
})();

View File

@@ -1,6 +1,6 @@
{ {
"name": "bybit-api", "name": "bybit-api",
"version": "3.3.8", "version": "3.3.9",
"description": "Complete & robust node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & integration tests.", "description": "Complete & robust node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & integration tests.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@@ -85,9 +85,10 @@ export class CopyTradingClient extends BaseRestClient {
closeOrder( closeOrder(
params: CopyTradingCloseOrderRequest params: CopyTradingCloseOrderRequest
): Promise<APIResponseV3<any>> { ): Promise<APIResponseV3<any>> {
return this.postPrivate('/contract/v3/private/copytrading/order/close', { return this.postPrivate(
params, '/contract/v3/private/copytrading/order/close',
}); params
);
} }
/** -> Positions API */ /** -> Positions API */

View File

@@ -788,7 +788,13 @@ export class WebsocketClient extends EventEmitter {
// TODO: persistence not working yet for spot v1 topics // TODO: persistence not working yet for spot v1 topics
if (wsKey !== WS_KEY_MAP.spotPublic && wsKey !== WS_KEY_MAP.spotPrivate) { if (wsKey !== WS_KEY_MAP.spotPublic && wsKey !== WS_KEY_MAP.spotPrivate) {
this.requestSubscribeTopics(wsKey, [...this.wsStore.getTopics(wsKey)]); const topics = [...this.wsStore.getTopics(wsKey)];
this.logger.info('Subscribing to topics', {
...loggerCategory,
wsKey,
topics,
});
this.requestSubscribeTopics(wsKey, topics);
} }
this.wsStore.get(wsKey, true)!.activePingTimer = setInterval( this.wsStore.get(wsKey, true)!.activePingTimer = setInterval(