upstox-js-sdk
Version:
The official Node Js client for communicating with the Upstox API
256 lines (232 loc) • 8.77 kB
JavaScript
/*
* Upstox Developer API
* Build your App on the Upstox platform  # Introduction Upstox API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (using Websocket), and more, with the easy to understand API collection. All requests are over HTTPS and the requests are sent with the content-type ‘application/json’. Developers have the option of choosing the response type as JSON or CSV for a few API calls. To be able to use these APIs you need to create an App in the Developer Console and generate your **apiKey** and **apiSecret**. You can use a redirect URL which will be called after the login flow. If you are a **trader**, you can directly create apps from Upstox mobile app or the desktop platform itself from **Apps** sections inside the **Account** Tab. Head over to <a href=\"http://account.upstox.com/developer/apps\" target=\"_blank\">account.upstox.com/developer/apps</a>.</br> If you are a **business** looking to integrate Upstox APIs, reach out to us and we will get a custom app created for you in no time. It is highly recommended that you do not embed the **apiSecret** in your frontend app. Create a remote backend which does the handshake on behalf of the frontend app. Marking the apiSecret in the frontend app will make your app vulnerable to threats and potential issues.
*
* OpenAPI spec version: v2
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 3.0.46
*
* Do not edit the class manually.
*
*/
import {ApiClient} from '../ApiClient';
/**
* The PlaceOrderRequest model module.
* @module model/PlaceOrderRequest
* @version v2
*/
export class PlaceOrderRequest {
/**
* Constructs a new <code>PlaceOrderRequest</code>.
* @alias module:model/PlaceOrderRequest
* @class
* @param quantity {Number} Quantity with which the order is to be placed
* @param product {module:model/PlaceOrderRequest.ProductEnum} Signifies if the order was either Intraday, Delivery, CO or OCO
* @param validity {module:model/PlaceOrderRequest.ValidityEnum} It can be one of the following - DAY(default), IOC
* @param price {Number} Price at which the order will be placed
* @param instrumentToken {String} Key of the instrument
* @param orderType {module:model/PlaceOrderRequest.OrderTypeEnum} Type of order. It can be one of the following MARKET refers to market order LIMIT refers to Limit Order SL refers to Stop Loss Limit SL-M refers to Stop Loss Market
* @param transactionType {module:model/PlaceOrderRequest.TransactionTypeEnum} Indicates whether its a buy or sell order
* @param disclosedQuantity {Number} The quantity that should be disclosed in the market depth
* @param triggerPrice {Number} If the order is a stop loss order then the trigger price to be set is mentioned here
* @param isAmo {Boolean} Signifies if the order is an After Market Order
*/
constructor(quantity, product, validity, price, instrumentToken, orderType, transactionType, disclosedQuantity, triggerPrice, isAmo) {
this.quantity = quantity;
this.product = product;
this.validity = validity;
this.price = price;
this.instrumentToken = instrumentToken;
this.orderType = orderType;
this.transactionType = transactionType;
this.disclosedQuantity = disclosedQuantity;
this.triggerPrice = triggerPrice;
this.isAmo = isAmo;
}
/**
* Constructs a <code>PlaceOrderRequest</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/PlaceOrderRequest} obj Optional instance to populate.
* @return {module:model/PlaceOrderRequest} The populated <code>PlaceOrderRequest</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new PlaceOrderRequest();
if (data.hasOwnProperty('quantity'))
obj.quantity = ApiClient.convertToType(data['quantity'], 'Number');
if (data.hasOwnProperty('product'))
obj.product = ApiClient.convertToType(data['product'], 'String');
if (data.hasOwnProperty('validity'))
obj.validity = ApiClient.convertToType(data['validity'], 'String');
if (data.hasOwnProperty('price'))
obj.price = ApiClient.convertToType(data['price'], 'Number');
if (data.hasOwnProperty('tag'))
obj.tag = ApiClient.convertToType(data['tag'], 'String');
if (data.hasOwnProperty('instrument_token'))
obj.instrumentToken = ApiClient.convertToType(data['instrument_token'], 'String');
if (data.hasOwnProperty('order_type'))
obj.orderType = ApiClient.convertToType(data['order_type'], 'String');
if (data.hasOwnProperty('transaction_type'))
obj.transactionType = ApiClient.convertToType(data['transaction_type'], 'String');
if (data.hasOwnProperty('disclosed_quantity'))
obj.disclosedQuantity = ApiClient.convertToType(data['disclosed_quantity'], 'Number');
if (data.hasOwnProperty('trigger_price'))
obj.triggerPrice = ApiClient.convertToType(data['trigger_price'], 'Number');
if (data.hasOwnProperty('is_amo'))
obj.isAmo = ApiClient.convertToType(data['is_amo'], 'Boolean');
}
return obj;
}
}
/**
* Quantity with which the order is to be placed
* @member {Number} quantity
*/
PlaceOrderRequest.prototype.quantity = undefined;
/**
* Allowed values for the <code>product</code> property.
* @enum {String}
* @readonly
*/
PlaceOrderRequest.ProductEnum = {
/**
* value: "I"
* @const
*/
I: "I",
/**
* value: "D"
* @const
*/
D: "D",
/**
* value: "CO"
* @const
*/
CO: "CO",
/**
* value: "OCO"
* @const
*/
OCO: "OCO",
/**
* value: "MTF"
* @const
*/
MTF: "MTF"
};
/**
* Signifies if the order was either Intraday, Delivery, CO or OCO
* @member {module:model/PlaceOrderRequest.ProductEnum} product
*/
PlaceOrderRequest.prototype.product = undefined;
/**
* Allowed values for the <code>validity</code> property.
* @enum {String}
* @readonly
*/
PlaceOrderRequest.ValidityEnum = {
/**
* value: "DAY"
* @const
*/
DAY: "DAY",
/**
* value: "IOC"
* @const
*/
IOC: "IOC"
};
/**
* It can be one of the following - DAY(default), IOC
* @member {module:model/PlaceOrderRequest.ValidityEnum} validity
*/
PlaceOrderRequest.prototype.validity = undefined;
/**
* Price at which the order will be placed
* @member {Number} price
*/
PlaceOrderRequest.prototype.price = undefined;
/**
* Tag for a particular order
* @member {String} tag
*/
PlaceOrderRequest.prototype.tag = undefined;
/**
* Key of the instrument
* @member {String} instrumentToken
*/
PlaceOrderRequest.prototype.instrumentToken = undefined;
/**
* Allowed values for the <code>orderType</code> property.
* @enum {String}
* @readonly
*/
PlaceOrderRequest.OrderTypeEnum = {
/**
* value: "MARKET"
* @const
*/
MARKET: "MARKET",
/**
* value: "LIMIT"
* @const
*/
LIMIT: "LIMIT",
/**
* value: "SL"
* @const
*/
SL: "SL",
/**
* value: "SL-M"
* @const
*/
SL_M: "SL-M"
};
/**
* Type of order. It can be one of the following MARKET refers to market order LIMIT refers to Limit Order SL refers to Stop Loss Limit SL-M refers to Stop Loss Market
* @member {module:model/PlaceOrderRequest.OrderTypeEnum} orderType
*/
PlaceOrderRequest.prototype.orderType = undefined;
/**
* Allowed values for the <code>transactionType</code> property.
* @enum {String}
* @readonly
*/
PlaceOrderRequest.TransactionTypeEnum = {
/**
* value: "BUY"
* @const
*/
BUY: "BUY",
/**
* value: "SELL"
* @const
*/
SELL: "SELL"
};
/**
* Indicates whether its a buy or sell order
* @member {module:model/PlaceOrderRequest.TransactionTypeEnum} transactionType
*/
PlaceOrderRequest.prototype.transactionType = undefined;
/**
* The quantity that should be disclosed in the market depth
* @member {Number} disclosedQuantity
*/
PlaceOrderRequest.prototype.disclosedQuantity = undefined;
/**
* If the order is a stop loss order then the trigger price to be set is mentioned here
* @member {Number} triggerPrice
*/
PlaceOrderRequest.prototype.triggerPrice = undefined;
/**
* Signifies if the order is an After Market Order
* @member {Boolean} isAmo
*/
PlaceOrderRequest.prototype.isAmo = undefined;