node-dsx-api
Version:
Node api for DSX.uk crypto exchange
43 lines (42 loc) • 1.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const exchange_1 = require("./exchange");
var OrderStatusType;
(function (OrderStatusType) {
OrderStatusType[OrderStatusType["Active"] = 0] = "Active";
OrderStatusType[OrderStatusType["Filled"] = 1] = "Filled";
OrderStatusType[OrderStatusType["Killed"] = 2] = "Killed";
OrderStatusType[OrderStatusType["Killing"] = 3] = "Killing";
OrderStatusType[OrderStatusType["Rejected"] = 7] = "Rejected";
})(OrderStatusType = exports.OrderStatusType || (exports.OrderStatusType = {}));
class ExchangeOrder extends exchange_1.Exchange {
async createOrder(req) {
const res = await this.request(this.sign("order/new", "tapi", "POST", req));
if (res.success != 1) {
throw res;
}
return res.return;
}
async cancelOrder(orderId) {
const res = await this.request(this.sign("order/cancel", "tapi", "POST", { orderId }));
if (res.success != 1) {
throw res;
}
return res.return;
}
async cancelAllOrders() {
const res = await this.request(this.sign("order/cancel/all", "tapi", "POST"));
if (res.success != 1) {
throw res;
}
return res.return;
}
async getOrderStatus(orderId) {
const res = await this.request(this.sign("order/status", "tapi", "POST", { orderId }));
if (res.success != 1) {
throw res;
}
return res.return;
}
}
exports.ExchangeOrder = ExchangeOrder;