Merge pull request #188 from tiagosiebler/spotv3
feat(#187, v3.1.2): add support for new orderCategory param for spotv3
This commit is contained in:
12
README.md
12
README.md
@@ -53,14 +53,20 @@ The version on npm is the output from the `build` command and can be used in pro
|
||||
Each REST API group has a dedicated REST client. To avoid confusion, here are the available REST clients and the corresponding API groups:
|
||||
| Class | Description |
|
||||
|:------------------------------------------------------------------: |:----------------------------------------------------------------------------------------------------------------------------: |
|
||||
| [ **Derivatives v3** ] | The Derivatves v3 APIs (successor to the Futures V2 APIs) |
|
||||
| [UnifiedMarginClient](src/unified-margin-client.ts) | [Derivatives (v3) Unified Margin APIs](https://bybit-exchange.github.io/docs/derivativesV3/unified_margin/#t-introduction) |
|
||||
| [ContractClient](src/contract-client.ts) | [Derivatives (v3) Contract APIs](https://bybit-exchange.github.io/docs/derivativesV3/contract). |
|
||||
| [ **Futures v2** ] | The Futures v2 APIs |
|
||||
| [InverseClient](src/inverse-client.ts) | [Inverse Perpetual Futures (v2) APIs](https://bybit-exchange.github.io/docs/futuresV2/inverse/) |
|
||||
| [LinearClient](src/linear-client.ts) | [USDT Perpetual Futures (v2) APIs](https://bybit-exchange.github.io/docs/futuresV2/linear/#t-introduction) |
|
||||
| [InverseFuturesClient](src/inverse-futures-client.ts) | [Inverse Futures (v2) APIs](https://bybit-exchange.github.io/docs/futuresV2/inverse_futures/#t-introduction) |
|
||||
| [ **Spot** ] | The spot APIs |
|
||||
| [SpotClientV3](src/spot-client-v3.ts) | [Spot Market (v3) APIs](https://bybit-exchange.github.io/docs/spot/v3/#t-introduction) |
|
||||
| [~SpotClient~](src/spot-client.ts) (deprecated, SpotClientV3 recommended)| [Spot Market (v1) APIs](https://bybit-exchange.github.io/docs/spot/v1/#t-introduction) |
|
||||
| [ **USDC Contract** ] | The USDC Contract APIs |
|
||||
| [USDCPerpetualClient](src/usdc-perpetual-client.ts) | [USDC Perpetual APIs](https://bybit-exchange.github.io/docs/usdc/option/?console#t-querydeliverylog) |
|
||||
| [USDCOptionClient](src/usdc-option-client.ts) | [USDC Option APIs](https://bybit-exchange.github.io/docs/usdc/option/#t-introduction) |
|
||||
| [UnifiedMarginClient](src/unified-margin-client.ts) | [Derivatives (v3) unified margin APIs](https://bybit-exchange.github.io/docs/derivativesV3/unified_margin/#t-introduction) |
|
||||
| [SpotClientV3](src/spot-client-v3.ts) | [Spot Market (v3) APIs](https://bybit-exchange.github.io/docs/spot/v3/#t-introduction) |
|
||||
| [~SpotClient~](src/spot-client.ts) (deprecated, v3 client recommended)| [Spot Market (v1) APIs](https://bybit-exchange.github.io/docs/spot/v1/#t-introduction) |
|
||||
| [ **Other** ] | Other standalone API groups |
|
||||
| [AccountAssetClient](src/account-asset-client.ts) | [Account Asset APIs](https://bybit-exchange.github.io/docs/account_asset/#t-introduction) |
|
||||
| [CopyTradingClient](src/copy-trading-client.ts) | [Copy Trading APIs](https://bybit-exchange.github.io/docs/copy_trading/#t-introduction) |
|
||||
| [WebsocketClient](src/websocket-client.ts) | All WebSocket Events (Public & Private for all API categories) |
|
||||
|
||||
@@ -16,7 +16,7 @@ import { WebsocketClient, WS_KEY_MAP, DefaultLogger } from '../src';
|
||||
const market = 'linear';
|
||||
// Inverse Perp
|
||||
// const market = 'inverse';
|
||||
// const market = 'spot';
|
||||
// const market = 'spotv3';
|
||||
|
||||
// Note: the WebsocketClient defaults to testnet. Set `livenet: true` to use live markets.
|
||||
const wsClient = new WebsocketClient(
|
||||
@@ -50,5 +50,6 @@ import { WebsocketClient, WS_KEY_MAP, DefaultLogger } from '../src';
|
||||
});
|
||||
|
||||
// subscribe to private endpoints
|
||||
// check the api docs in your api category to see the available topics
|
||||
wsClient.subscribe(['position', 'execution', 'order', 'wallet']);
|
||||
})();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bybit-api",
|
||||
"version": "3.1.1",
|
||||
"version": "3.1.2",
|
||||
"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",
|
||||
|
||||
@@ -145,12 +145,14 @@ export class SpotClientV3 extends BaseRestClient {
|
||||
getOpenOrders(
|
||||
symbol?: string,
|
||||
orderId?: string,
|
||||
limit?: number
|
||||
limit?: number,
|
||||
orderCategory?: 0 | 1
|
||||
): Promise<APIResponseV3<any>> {
|
||||
return this.getPrivate('/spot/v3/private/open-orders', {
|
||||
symbol,
|
||||
orderId,
|
||||
limit,
|
||||
orderCategory,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,7 +160,8 @@ export class SpotClientV3 extends BaseRestClient {
|
||||
getPastOrders(
|
||||
symbol?: string,
|
||||
orderId?: string,
|
||||
limit?: number
|
||||
limit?: number,
|
||||
orderCategory?: 0 | 1
|
||||
): Promise<APIResponseV3<any>> {
|
||||
return this.getPrivate('/spot/v3/private/history-orders', {
|
||||
symbol,
|
||||
|
||||
@@ -29,11 +29,13 @@ export interface SpotCancelOrderBatchRequest {
|
||||
symbol: string;
|
||||
side?: OrderSide;
|
||||
orderTypes: OrderTypeSpot[];
|
||||
orderCategory?: 0 | 1;
|
||||
}
|
||||
|
||||
export interface SpotOrderQueryById {
|
||||
orderId?: string;
|
||||
orderLinkId?: string;
|
||||
orderCategory?: 0 | 1;
|
||||
}
|
||||
|
||||
export interface SpotSymbolInfo {
|
||||
|
||||
@@ -60,7 +60,7 @@ export interface UMOrderRequest {
|
||||
category: UMCategory;
|
||||
symbol: string;
|
||||
side: OrderSide;
|
||||
positionIdx?: '0';
|
||||
positionIdx?: '0' | '1' | '2';
|
||||
orderType: UMOrderType;
|
||||
qty: string;
|
||||
price?: string;
|
||||
|
||||
@@ -154,7 +154,8 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
|
||||
take_profit: 50000,
|
||||
})
|
||||
).toMatchObject({
|
||||
ret_code: API_ERROR_CODE.POSITION_STATUS_NOT_NORMAL,
|
||||
// seems to fluctuate between POSITION_STATUS_NOT_NORMAL and POSITION_IDX_NOT_MATCH_POSITION_MODE
|
||||
ret_code: /^30013|30041$/,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user