diff --git a/examples/rest-copy-private.ts b/examples/rest-copy-private.ts new file mode 100644 index 0000000..724ced0 --- /dev/null +++ b/examples/rest-copy-private.ts @@ -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); + } +})(); diff --git a/package.json b/package.json index 4ffa466..32db6b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/copy-trading-client.ts b/src/copy-trading-client.ts index 0162f36..0247da3 100644 --- a/src/copy-trading-client.ts +++ b/src/copy-trading-client.ts @@ -85,9 +85,10 @@ export class CopyTradingClient extends BaseRestClient { closeOrder( params: CopyTradingCloseOrderRequest ): Promise> { - return this.postPrivate('/contract/v3/private/copytrading/order/close', { - params, - }); + return this.postPrivate( + '/contract/v3/private/copytrading/order/close', + params + ); } /** -> Positions API */ diff --git a/src/websocket-client.ts b/src/websocket-client.ts index bfe430c..c3b7846 100644 --- a/src/websocket-client.ts +++ b/src/websocket-client.ts @@ -788,7 +788,13 @@ export class WebsocketClient extends EventEmitter { // TODO: persistence not working yet for spot v1 topics 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( diff --git a/test/unified-margin/private.read.test.ts b/test/unified-margin/private.read.test.ts index be2ef35..ed809fc 100644 --- a/test/unified-margin/private.read.test.ts +++ b/test/unified-margin/private.read.test.ts @@ -36,7 +36,7 @@ describe('Private Unified Margin REST API GET Endpoints', () => { 'fb56c285-02ac-424e-a6b1-d10413b65fab%3A1668178953132%2Cfb56c285-02ac-424e-a6b1-d10413b65fab%3A1668178953132'; expect(await api.getHistoricOrders({ category, cursor })).toMatchObject({ retCode: API_ERROR_CODE.ACCOUNT_NOT_UNIFIED, - retMsg: expect.stringMatching(/not.*unified margin/gim), + // retMsg: expect.stringMatching(/not.*unified margin/gim), }); });