Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.5.11: active-orders endpoints [BAC-2110] #149

Merged
merged 1 commit into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dydxprotocol/v3-client",
"version": "1.5.10",
"version": "1.5.11",
"description": "Trading client library for the new dYdX system (v3 API)",
"main": "build/src/index.js",
"scripts": {
Expand Down
55 changes: 55 additions & 0 deletions src/modules/private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
TransferParams,
TransferResponseObject,
UserResponseObject,
ActiveOrderResponseObject,
} from '../types';
import Clock from './clock';

Expand Down Expand Up @@ -360,6 +361,33 @@ export default class Private {
);
}

/**
* @description get active orders (PENDING, OPEN, UNTRIGGERED) for a user by a set of query
* parameters - if id is included then side is required
*
* @param {
* @market the orders are for
* @side of the book the orders are on
* @id of the order
* }
*/
async getActiveOrders(
market: Market,
side?: OrderSide,
id?: string,
genericParams: GenericParams = {},
): Promise<{ orders: ActiveOrderResponseObject[] }> {
return this._get(
'active-orders',
{
market,
side,
id,
...genericParams,
},
);
}

/**
* @description get an order by a unique id
*
Expand Down Expand Up @@ -471,6 +499,33 @@ export default class Private {
);
}

/**
* @description cancel active orders (PENDING, OPEN, UNTRIGGERED) for a user by a set of query
* parameters - if id is included then side is required
*
* @param {
* @market the orders are for
* @side of the book the orders are on
* @id of the order
* }
*/
async cancelActiveOrders(
market: Market,
side?: OrderSide,
id?: string,
genericParams: GenericParams = {},
): Promise<{ cancelOrders: ActiveOrderResponseObject[] }> {
return this.delete(
'active-orders',
{
market,
side,
id,
...genericParams,
},
);
}

/**
*@description get fills for a user by a set of query parameters
*
Expand Down
9 changes: 9 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,15 @@ export interface OrderResponseObject {
cancelReason?: string | null;
}

export interface ActiveOrderResponseObject {
id: string;
accountId: string;
remainingSize: string;
price: string;
market: Market;
side: OrderSide;
}

export interface PositionResponseObject {
market: Market;
status: PositionStatus;
Expand Down