UNPKG

kucoin-universal-sdk

Version:
421 lines 16.2 kB
"use strict"; // Code generated by Kucoin Universal SDK Generator; DO NOT EDIT. Object.defineProperty(exports, "__esModule", { value: true }); exports.AddOrderTestReqBuilder = exports.AddOrderTestReq = void 0; const class_transformer_1 = require("class-transformer"); class AddOrderTestReq { /** * Private constructor, please use the corresponding static methods to construct the object. */ constructor() { /** * specify if the order is an \'limit\' order or \'market\' order */ this.type = AddOrderTestReq.TypeEnum.LIMIT; /** * A mark to reduce the position size only. Set to false by default. Need to set the position size when reduceOnly is true. If set to true, only the orders reducing the position size will be executed. If the reduce-only order size exceeds the position size, the extra size will be canceled. */ this.reduceOnly = false; /** * A mark to close the position. Set to false by default. If closeOrder is set to true, the system will close the position and the position size will become 0. Side, Size and Leverage fields can be left empty and the system will determine the side and size automatically. */ this.closeOrder = false; /** * A mark to forcely hold the funds for an order, even though it\'s an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default. The system will forcely freeze certain amount of funds for this order, including orders whose direction is opposite to the current positions. This feature is to ensure that the order won’t be canceled by the matching engine in such a circumstance that not enough funds are frozen for the order. */ this.forceHold = false; /** * Margin mode: ISOLATED, CROSS, default: ISOLATED */ this.marginMode = AddOrderTestReq.MarginModeEnum.ISOLATED; /** * Optional for type is \'limit\' order, [Time in force](https://www.kucoin.com/docs-new/doc-338146) is a special strategy used during trading, default is GTC */ this.timeInForce = AddOrderTestReq.TimeInForceEnum.GOOD_TILL_CANCELED; /** * Optional for type is \'limit\' order, post only flag, invalid when timeInForce is IOC. When postOnly is true, not allowed choose hidden or iceberg. The post-only flag ensures that the trader always pays the maker fee and provides liquidity to the order book. If any part of the order is going to pay taker fee, the order will be fully rejected. */ this.postOnly = false; /** * Optional for type is \'limit\' order, orders not displaying in order book. When hidden chose, not allowed choose postOnly. */ this.hidden = false; /** * Optional for type is \'limit\' order, Only visible portion of the order is displayed in the order book. When iceberg chose, not allowed choose postOnly. */ this.iceberg = false; // @ts-ignore this.clientOid = null; // @ts-ignore this.side = null; // @ts-ignore this.symbol = null; // @ts-ignore this.leverage = null; // @ts-ignore this.type = null; } /** * Creates a new instance of the `AddOrderTestReq` class. * The builder pattern allows step-by-step construction of a `AddOrderTestReq` object. */ static builder() { return new AddOrderTestReqBuilder(new AddOrderTestReq()); } /** * Creates a new instance of the `AddOrderTestReq` class with the given data. */ static create(data) { let obj = new AddOrderTestReq(); obj.clientOid = data.clientOid; obj.side = data.side; obj.symbol = data.symbol; obj.leverage = data.leverage; if (data.type) { obj.type = data.type; } else { obj.type = AddOrderTestReq.TypeEnum.LIMIT; } obj.remark = data.remark; obj.stop = data.stop; obj.stopPriceType = data.stopPriceType; obj.stopPrice = data.stopPrice; if (data.reduceOnly) { obj.reduceOnly = data.reduceOnly; } else { obj.reduceOnly = false; } if (data.closeOrder) { obj.closeOrder = data.closeOrder; } else { obj.closeOrder = false; } if (data.forceHold) { obj.forceHold = data.forceHold; } else { obj.forceHold = false; } obj.stp = data.stp; if (data.marginMode) { obj.marginMode = data.marginMode; } else { obj.marginMode = AddOrderTestReq.MarginModeEnum.ISOLATED; } obj.price = data.price; obj.size = data.size; if (data.timeInForce) { obj.timeInForce = data.timeInForce; } else { obj.timeInForce = AddOrderTestReq.TimeInForceEnum.GOOD_TILL_CANCELED; } if (data.postOnly) { obj.postOnly = data.postOnly; } else { obj.postOnly = false; } if (data.hidden) { obj.hidden = data.hidden; } else { obj.hidden = false; } if (data.iceberg) { obj.iceberg = data.iceberg; } else { obj.iceberg = false; } obj.visibleSize = data.visibleSize; obj.qty = data.qty; obj.valueQty = data.valueQty; return obj; } /** * Convert the object to a JSON string. */ toJson() { return JSON.stringify((0, class_transformer_1.instanceToPlain)(this)); } /** * Create an object from a JSON string. */ static fromJson(input) { return this.fromObject(JSON.parse(input)); } /** * Create an object from Js Object. */ static fromObject(jsonObject) { return (0, class_transformer_1.plainToClassFromExist)(new AddOrderTestReq(), jsonObject); } } exports.AddOrderTestReq = AddOrderTestReq; (function (AddOrderTestReq) { let SideEnum; (function (SideEnum) { /** * */ SideEnum[SideEnum["BUY"] = 'buy'] = "BUY"; /** * */ SideEnum[SideEnum["SELL"] = 'sell'] = "SELL"; })(SideEnum = AddOrderTestReq.SideEnum || (AddOrderTestReq.SideEnum = {})); let TypeEnum; (function (TypeEnum) { /** * */ TypeEnum[TypeEnum["LIMIT"] = 'limit'] = "LIMIT"; /** * */ TypeEnum[TypeEnum["MARKET"] = 'market'] = "MARKET"; })(TypeEnum = AddOrderTestReq.TypeEnum || (AddOrderTestReq.TypeEnum = {})); let StopEnum; (function (StopEnum) { /** * Triggers when the price reaches or goes below the stopPrice. */ StopEnum[StopEnum["DOWN"] = 'down'] = "DOWN"; /** * Triggers when the price reaches or goes above the stopPrice */ StopEnum[StopEnum["UP"] = 'up'] = "UP"; })(StopEnum = AddOrderTestReq.StopEnum || (AddOrderTestReq.StopEnum = {})); let StopPriceTypeEnum; (function (StopPriceTypeEnum) { /** * TP for trade price, The last trade price is the last price at which an order was filled. This price can be found in the latest match message. */ StopPriceTypeEnum[StopPriceTypeEnum["TRADE_PRICE"] = 'TP'] = "TRADE_PRICE"; /** * MP for mark price, The mark price can be obtained through relevant OPEN API for index services */ StopPriceTypeEnum[StopPriceTypeEnum["MARK_PRICE"] = 'MP'] = "MARK_PRICE"; /** * IP for index price, The index price can be obtained through relevant OPEN API for index services */ StopPriceTypeEnum[StopPriceTypeEnum["INDEX_PRICE"] = 'IP'] = "INDEX_PRICE"; })(StopPriceTypeEnum = AddOrderTestReq.StopPriceTypeEnum || (AddOrderTestReq.StopPriceTypeEnum = {})); let StpEnum; (function (StpEnum) { /** * Cancel new, Cancel the new order */ StpEnum[StpEnum["CN"] = 'CN'] = "CN"; /** * Cancel old, Cancel the old order */ StpEnum[StpEnum["CO"] = 'CO'] = "CO"; /** * Cancel both, Cancel both sides */ StpEnum[StpEnum["CB"] = 'CB'] = "CB"; })(StpEnum = AddOrderTestReq.StpEnum || (AddOrderTestReq.StpEnum = {})); let MarginModeEnum; (function (MarginModeEnum) { /** * */ MarginModeEnum[MarginModeEnum["ISOLATED"] = 'ISOLATED'] = "ISOLATED"; /** * */ MarginModeEnum[MarginModeEnum["CROSS"] = 'CROSS'] = "CROSS"; })(MarginModeEnum = AddOrderTestReq.MarginModeEnum || (AddOrderTestReq.MarginModeEnum = {})); let TimeInForceEnum; (function (TimeInForceEnum) { /** * order remains open on the order book until canceled. This is the default type if the field is left empty. */ TimeInForceEnum[TimeInForceEnum["GOOD_TILL_CANCELED"] = 'GTC'] = "GOOD_TILL_CANCELED"; /** * being matched or not, the remaining size of the order will be instantly canceled instead of entering the order book. */ TimeInForceEnum[TimeInForceEnum["IMMEDIATE_OR_CANCEL"] = 'IOC'] = "IMMEDIATE_OR_CANCEL"; })(TimeInForceEnum = AddOrderTestReq.TimeInForceEnum || (AddOrderTestReq.TimeInForceEnum = {})); })(AddOrderTestReq || (exports.AddOrderTestReq = AddOrderTestReq = {})); class AddOrderTestReqBuilder { constructor(obj) { this.obj = obj; this.obj = obj; } /** * Unique order id created by users to identify their orders, the maximum length cannot exceed 40, e.g. UUID, Only allows numbers, characters, underline(_), and separator(-) */ setClientOid(value) { this.obj.clientOid = value; return this; } /** * specify if the order is to \'buy\' or \'sell\' */ setSide(value) { this.obj.side = value; return this; } /** * Symbol of the contract, Please refer to [Get Symbol endpoint: symbol](https://www.kucoin.com/docs-new/api-3470220) */ setSymbol(value) { this.obj.symbol = value; return this; } /** * Used to calculate the margin to be frozen for the order. If you are to close the position, this parameter is not required. */ setLeverage(value) { this.obj.leverage = value; return this; } /** * specify if the order is an \'limit\' order or \'market\' order */ setType(value) { this.obj.type = value; return this; } /** * remark for the order, length cannot exceed 100 utf8 characters */ setRemark(value) { this.obj.remark = value; return this; } /** * Either \'down\' or \'up\'. If stop is used,parameter stopPrice and stopPriceType also need to be provieded. */ setStop(value) { this.obj.stop = value; return this; } /** * Either \'TP\', \'IP\' or \'MP\', Need to be defined if stop is specified. */ setStopPriceType(value) { this.obj.stopPriceType = value; return this; } /** * Need to be defined if stop is specified. */ setStopPrice(value) { this.obj.stopPrice = value; return this; } /** * A mark to reduce the position size only. Set to false by default. Need to set the position size when reduceOnly is true. If set to true, only the orders reducing the position size will be executed. If the reduce-only order size exceeds the position size, the extra size will be canceled. */ setReduceOnly(value) { this.obj.reduceOnly = value; return this; } /** * A mark to close the position. Set to false by default. If closeOrder is set to true, the system will close the position and the position size will become 0. Side, Size and Leverage fields can be left empty and the system will determine the side and size automatically. */ setCloseOrder(value) { this.obj.closeOrder = value; return this; } /** * A mark to forcely hold the funds for an order, even though it\'s an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default. The system will forcely freeze certain amount of funds for this order, including orders whose direction is opposite to the current positions. This feature is to ensure that the order won’t be canceled by the matching engine in such a circumstance that not enough funds are frozen for the order. */ setForceHold(value) { this.obj.forceHold = value; return this; } /** * [Self Trade Prevention](https://www.kucoin.com/docs-new/doc-338146) is divided into these strategies: CN, CO, CB. Not supported DC at the moment. */ setStp(value) { this.obj.stp = value; return this; } /** * Margin mode: ISOLATED, CROSS, default: ISOLATED */ setMarginMode(value) { this.obj.marginMode = value; return this; } /** * Required for type is \'limit\' order, indicating the operating price */ setPrice(value) { this.obj.price = value; return this; } /** * **Choose one of size, qty, valueQty**, Order size (Lot), must be a positive integer. The quantity unit of coin-swap contracts is size(lot), and other units are not supported. */ setSize(value) { this.obj.size = value; return this; } /** * Optional for type is \'limit\' order, [Time in force](https://www.kucoin.com/docs-new/doc-338146) is a special strategy used during trading, default is GTC */ setTimeInForce(value) { this.obj.timeInForce = value; return this; } /** * Optional for type is \'limit\' order, post only flag, invalid when timeInForce is IOC. When postOnly is true, not allowed choose hidden or iceberg. The post-only flag ensures that the trader always pays the maker fee and provides liquidity to the order book. If any part of the order is going to pay taker fee, the order will be fully rejected. */ setPostOnly(value) { this.obj.postOnly = value; return this; } /** * Optional for type is \'limit\' order, orders not displaying in order book. When hidden chose, not allowed choose postOnly. */ setHidden(value) { this.obj.hidden = value; return this; } /** * Optional for type is \'limit\' order, Only visible portion of the order is displayed in the order book. When iceberg chose, not allowed choose postOnly. */ setIceberg(value) { this.obj.iceberg = value; return this; } /** * Optional for type is \'limit\' order, The maximum visible size of an iceberg order. please place order in size (lots), The units of qty (base currency) and valueQty (value) are not supported. Need to be defined if iceberg is specified. */ setVisibleSize(value) { this.obj.visibleSize = value; return this; } /** * **Choose one of size, qty, valueQty**, Order size (Base currency) must be an integer multiple of the multiplier. The unit of the quantity of coin-swap is size(lot), which is not supported */ setQty(value) { this.obj.qty = value; return this; } /** * **Choose one of size, qty, valueQty**, Order size (Value), USDS-Swap correspond to USDT or USDC. The unit of the quantity of coin-swap is size(lot), which is not supported */ setValueQty(value) { this.obj.valueQty = value; return this; } /** * Get the final object. */ build() { return this.obj; } } exports.AddOrderTestReqBuilder = AddOrderTestReqBuilder; //# sourceMappingURL=model_add_order_test_req.js.map