kucoin-universal-sdk
Version:
Official KuCoin Universal SDK.
310 lines • 11.1 kB
JavaScript
"use strict";
// Code generated by Kucoin Universal SDK Generator; DO NOT EDIT.
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddStopOrderReqBuilder = exports.AddStopOrderReq = void 0;
const class_transformer_1 = require("class-transformer");
class AddStopOrderReq {
/**
* Private constructor, please use the corresponding static methods to construct the object.
*/
constructor() {
/**
* [Time in force](https://www.kucoin.com/docs-new/doc-338146) is a special strategy used during trading. Required for limit orders.
*/
this.timeInForce = AddStopOrderReq.TimeInForceEnum.GTC;
/**
* passive order labels, this is disabled when the order timing strategy is IOC or FOK if **type** is limit.
*/
this.postOnly = false;
/**
* [Hidden order](https://www.kucoin.com/docs-new/doc-338146) or not (not shown in order book)
*/
this.hidden = false;
/**
* Whether or not only visible portions of orders are shown in [Iceberg orders](https://www.kucoin.com/docs-new/doc-338146)
*/
this.iceberg = false;
/**
* Cancel after n seconds, the order timing strategy is GTT, -1 means it will not be cancelled automatically, the default value is -1
*/
this.cancelAfter = -1;
// @ts-ignore
this.side = null;
// @ts-ignore
this.symbol = null;
// @ts-ignore
this.type = null;
// @ts-ignore
this.stopPrice = null;
}
/**
* Creates a new instance of the `AddStopOrderReq` class.
* The builder pattern allows step-by-step construction of a `AddStopOrderReq` object.
*/
static builder() {
return new AddStopOrderReqBuilder(new AddStopOrderReq());
}
/**
* Creates a new instance of the `AddStopOrderReq` class with the given data.
*/
static create(data) {
let obj = new AddStopOrderReq();
obj.clientOid = data.clientOid;
obj.side = data.side;
obj.symbol = data.symbol;
obj.type = data.type;
obj.remark = data.remark;
obj.stp = data.stp;
obj.price = data.price;
obj.size = data.size;
if (data.timeInForce) {
obj.timeInForce = data.timeInForce;
}
else {
obj.timeInForce = AddStopOrderReq.TimeInForceEnum.GTC;
}
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;
if (data.cancelAfter) {
obj.cancelAfter = data.cancelAfter;
}
else {
obj.cancelAfter = -1;
}
obj.funds = data.funds;
obj.stopPrice = data.stopPrice;
obj.tradeType = data.tradeType;
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 AddStopOrderReq(), jsonObject);
}
}
exports.AddStopOrderReq = AddStopOrderReq;
(function (AddStopOrderReq) {
let SideEnum;
(function (SideEnum) {
/**
*
*/
SideEnum[SideEnum["BUY"] = 'buy'] = "BUY";
/**
*
*/
SideEnum[SideEnum["SELL"] = 'sell'] = "SELL";
})(SideEnum = AddStopOrderReq.SideEnum || (AddStopOrderReq.SideEnum = {}));
let TypeEnum;
(function (TypeEnum) {
/**
*
*/
TypeEnum[TypeEnum["LIMIT"] = 'limit'] = "LIMIT";
/**
*
*/
TypeEnum[TypeEnum["MARKET"] = 'market'] = "MARKET";
})(TypeEnum = AddStopOrderReq.TypeEnum || (AddStopOrderReq.TypeEnum = {}));
let StpEnum;
(function (StpEnum) {
/**
*
*/
StpEnum[StpEnum["DC"] = 'DC'] = "DC";
/**
*
*/
StpEnum[StpEnum["CO"] = 'CO'] = "CO";
/**
*
*/
StpEnum[StpEnum["CN"] = 'CN'] = "CN";
/**
*
*/
StpEnum[StpEnum["CB"] = 'CB'] = "CB";
})(StpEnum = AddStopOrderReq.StpEnum || (AddStopOrderReq.StpEnum = {}));
let TimeInForceEnum;
(function (TimeInForceEnum) {
/**
*
*/
TimeInForceEnum[TimeInForceEnum["GTC"] = 'GTC'] = "GTC";
/**
*
*/
TimeInForceEnum[TimeInForceEnum["GTT"] = 'GTT'] = "GTT";
/**
*
*/
TimeInForceEnum[TimeInForceEnum["IOC"] = 'IOC'] = "IOC";
/**
*
*/
TimeInForceEnum[TimeInForceEnum["FOK"] = 'FOK'] = "FOK";
})(TimeInForceEnum = AddStopOrderReq.TimeInForceEnum || (AddStopOrderReq.TimeInForceEnum = {}));
})(AddStopOrderReq || (exports.AddStopOrderReq = AddStopOrderReq = {}));
class AddStopOrderReqBuilder {
constructor(obj) {
this.obj = obj;
this.obj = obj;
}
/**
* Client Order Id,The ClientOid field is a unique ID created by the user(we recommend using a UUID), and can only contain numbers, letters, underscores (_), and hyphens (-). This field is returned when order information is obtained. You can use clientOid to tag your orders. ClientOid is different from the order ID created by the service provider. Please do not initiate requests using the same clientOid. The maximum length for the ClientOid is 40 characters. Please remember the orderId created by the service provider, it used to check for updates in order status.
*/
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
*/
setSymbol(value) {
this.obj.symbol = value;
return this;
}
/**
* specify if the order is an \'limit\' order or \'market\' order. The type of order you specify when you place your order determines whether or not you need to request other parameters and also affects the execution of the matching engine. When placing a limit order, you must specify a price and size. The system will try to match the order according to market price or a price better than market price. If the order cannot be immediately matched, it will stay in the order book until it is matched or the user cancels. Unlike limit orders, the price for market orders fluctuates with market prices. When placing a market order, you do not need to specify a price, you only need to specify a quantity. Market orders are filled immediately and will not enter the order book. All market orders are takers and a taker fee will be charged.
*/
setType(value) {
this.obj.type = value;
return this;
}
/**
* Order placement remarks, length cannot exceed 20 characters (ASCII)
*/
setRemark(value) {
this.obj.remark = value;
return this;
}
/**
* [Self Trade Prevention](https://www.kucoin.com/docs-new/doc-338146) is divided into four strategies: CN, CO, CB , and DC
*/
setStp(value) {
this.obj.stp = value;
return this;
}
/**
* Specify price for order, not need for market order. When placing a limit order, the price must be based on priceIncrement for the trading pair. The price increment (priceIncrement) is the price precision for the trading pair. For example, for the BTC-USDT trading pair, the priceIncrement is 0.00001000. So the price for your orders cannot be less than 0.00001000 and must be a multiple of priceIncrement. Otherwise, the order will return an invalid priceIncrement error.
*/
setPrice(value) {
this.obj.price = value;
return this;
}
/**
* Specify quantity for order When **type** is limit, size refers to the amount of trading targets (the asset name written in front) for the trading pair. Teh Size must be based on the baseIncrement of the trading pair. The baseIncrement represents the precision for the trading pair. The size of an order must be a positive-integer multiple of baseIncrement and must be between baseMinSize and baseMaxSize. When **type** is market, select one out of two: size or funds
*/
setSize(value) {
this.obj.size = value;
return this;
}
/**
* [Time in force](https://www.kucoin.com/docs-new/doc-338146) is a special strategy used during trading. Required for limit orders.
*/
setTimeInForce(value) {
this.obj.timeInForce = value;
return this;
}
/**
* passive order labels, this is disabled when the order timing strategy is IOC or FOK if **type** is limit.
*/
setPostOnly(value) {
this.obj.postOnly = value;
return this;
}
/**
* [Hidden order](https://www.kucoin.com/docs-new/doc-338146) or not (not shown in order book)
*/
setHidden(value) {
this.obj.hidden = value;
return this;
}
/**
* Whether or not only visible portions of orders are shown in [Iceberg orders](https://www.kucoin.com/docs-new/doc-338146)
*/
setIceberg(value) {
this.obj.iceberg = value;
return this;
}
/**
* When **type** is limit, this is Maximum visible quantity in iceberg orders.
*/
setVisibleSize(value) {
this.obj.visibleSize = value;
return this;
}
/**
* Cancel after n seconds, the order timing strategy is GTT, -1 means it will not be cancelled automatically, the default value is -1
*/
setCancelAfter(value) {
this.obj.cancelAfter = value;
return this;
}
/**
* When **type** is market, select one out of two: size or funds
*/
setFunds(value) {
this.obj.funds = value;
return this;
}
/**
* The trigger price.
*/
setStopPrice(value) {
this.obj.stopPrice = value;
return this;
}
/**
* The type of trading : TRADE(Spot), MARGIN_TRADE (Cross Margin), MARGIN_ISOLATED_TRADE (Isolated Margin). Default is TRADE
*/
setTradeType(value) {
this.obj.tradeType = value;
return this;
}
/**
* Get the final object.
*/
build() {
return this.obj;
}
}
exports.AddStopOrderReqBuilder = AddStopOrderReqBuilder;
//# sourceMappingURL=model_add_stop_order_req.js.map