upstox-js-sdk
Version:
The official Node Js client for communicating with the Upstox API
254 lines (222 loc) • 10.9 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PositionData = void 0;
var _ApiClient = require("../ApiClient");
/*
* 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.
*
*/
/**
* The PositionData model module.
* @module model/PositionData
* @version v2
*/
class PositionData {
/**
* Constructs a new <code>PositionData</code>.
* Response data for position details
* @alias module:model/PositionData
* @class
*/
constructor() {}
/**
* Constructs a <code>PositionData</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/PositionData} obj Optional instance to populate.
* @return {module:model/PositionData} The populated <code>PositionData</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new PositionData();
if (data.hasOwnProperty('exchange')) obj.exchange = _ApiClient.ApiClient.convertToType(data['exchange'], 'String');
if (data.hasOwnProperty('multiplier')) obj.multiplier = _ApiClient.ApiClient.convertToType(data['multiplier'], 'Number');
if (data.hasOwnProperty('value')) obj.value = _ApiClient.ApiClient.convertToType(data['value'], 'Number');
if (data.hasOwnProperty('pnl')) obj.pnl = _ApiClient.ApiClient.convertToType(data['pnl'], 'Number');
if (data.hasOwnProperty('product')) obj.product = _ApiClient.ApiClient.convertToType(data['product'], 'String');
if (data.hasOwnProperty('instrument_token')) obj.instrumentToken = _ApiClient.ApiClient.convertToType(data['instrument_token'], 'String');
if (data.hasOwnProperty('average_price')) obj.averagePrice = _ApiClient.ApiClient.convertToType(data['average_price'], 'Number');
if (data.hasOwnProperty('buy_value')) obj.buyValue = _ApiClient.ApiClient.convertToType(data['buy_value'], 'Number');
if (data.hasOwnProperty('overnight_quantity')) obj.overnightQuantity = _ApiClient.ApiClient.convertToType(data['overnight_quantity'], 'Number');
if (data.hasOwnProperty('day_buy_value')) obj.dayBuyValue = _ApiClient.ApiClient.convertToType(data['day_buy_value'], 'Number');
if (data.hasOwnProperty('day_buy_price')) obj.dayBuyPrice = _ApiClient.ApiClient.convertToType(data['day_buy_price'], 'Number');
if (data.hasOwnProperty('overnight_buy_amount')) obj.overnightBuyAmount = _ApiClient.ApiClient.convertToType(data['overnight_buy_amount'], 'Number');
if (data.hasOwnProperty('overnight_buy_quantity')) obj.overnightBuyQuantity = _ApiClient.ApiClient.convertToType(data['overnight_buy_quantity'], 'Number');
if (data.hasOwnProperty('day_buy_quantity')) obj.dayBuyQuantity = _ApiClient.ApiClient.convertToType(data['day_buy_quantity'], 'Number');
if (data.hasOwnProperty('day_sell_value')) obj.daySellValue = _ApiClient.ApiClient.convertToType(data['day_sell_value'], 'Number');
if (data.hasOwnProperty('day_sell_price')) obj.daySellPrice = _ApiClient.ApiClient.convertToType(data['day_sell_price'], 'Number');
if (data.hasOwnProperty('overnight_sell_amount')) obj.overnightSellAmount = _ApiClient.ApiClient.convertToType(data['overnight_sell_amount'], 'Number');
if (data.hasOwnProperty('overnight_sell_quantity')) obj.overnightSellQuantity = _ApiClient.ApiClient.convertToType(data['overnight_sell_quantity'], 'Number');
if (data.hasOwnProperty('day_sell_quantity')) obj.daySellQuantity = _ApiClient.ApiClient.convertToType(data['day_sell_quantity'], 'Number');
if (data.hasOwnProperty('quantity')) obj.quantity = _ApiClient.ApiClient.convertToType(data['quantity'], 'Number');
if (data.hasOwnProperty('last_price')) obj.lastPrice = _ApiClient.ApiClient.convertToType(data['last_price'], 'Number');
if (data.hasOwnProperty('unrealised')) obj.unrealised = _ApiClient.ApiClient.convertToType(data['unrealised'], 'Number');
if (data.hasOwnProperty('realised')) obj.realised = _ApiClient.ApiClient.convertToType(data['realised'], 'Number');
if (data.hasOwnProperty('sell_value')) obj.sellValue = _ApiClient.ApiClient.convertToType(data['sell_value'], 'Number');
if (data.hasOwnProperty('tradingsymbol')) obj.tradingsymbol = _ApiClient.ApiClient.convertToType(data['tradingsymbol'], 'String');
if (data.hasOwnProperty('trading_symbol')) obj.tradingSymbol = _ApiClient.ApiClient.convertToType(data['trading_symbol'], 'String');
if (data.hasOwnProperty('close_price')) obj.closePrice = _ApiClient.ApiClient.convertToType(data['close_price'], 'Number');
if (data.hasOwnProperty('buy_price')) obj.buyPrice = _ApiClient.ApiClient.convertToType(data['buy_price'], 'Number');
if (data.hasOwnProperty('sell_price')) obj.sellPrice = _ApiClient.ApiClient.convertToType(data['sell_price'], 'Number');
}
return obj;
}
}
/**
* Exchange to which the order is associated
* @member {String} exchange
*/
exports.PositionData = PositionData;
PositionData.prototype.exchange = undefined;
/**
* The quantity/lot size multiplier used for calculating P&Ls
* @member {Number} multiplier
*/
PositionData.prototype.multiplier = undefined;
/**
* Net value of the position
* @member {Number} value
*/
PositionData.prototype.value = undefined;
/**
* Profit and loss - net returns on the position
* @member {Number} pnl
*/
PositionData.prototype.pnl = undefined;
/**
* Shows if the order was either Intraday, Delivery, CO or OCO
* @member {String} product
*/
PositionData.prototype.product = undefined;
/**
* Key issued by Upstox for the instrument
* @member {String} instrumentToken
*/
PositionData.prototype.instrumentToken = undefined;
/**
* Average price at which the net position quantity was acquired
* @member {Number} averagePrice
*/
PositionData.prototype.averagePrice = undefined;
/**
* Net value of the bought quantities
* @member {Number} buyValue
*/
PositionData.prototype.buyValue = undefined;
/**
* Quantity held previously and carried forward over night
* @member {Number} overnightQuantity
*/
PositionData.prototype.overnightQuantity = undefined;
/**
* Amount at which the quantity is bought during the day
* @member {Number} dayBuyValue
*/
PositionData.prototype.dayBuyValue = undefined;
/**
* Average price at which the day qty was bought. Default is empty string
* @member {Number} dayBuyPrice
*/
PositionData.prototype.dayBuyPrice = undefined;
/**
* Amount at which the quantity was bought in the previous session
* @member {Number} overnightBuyAmount
*/
PositionData.prototype.overnightBuyAmount = undefined;
/**
* Quantity bought in the previous session
* @member {Number} overnightBuyQuantity
*/
PositionData.prototype.overnightBuyQuantity = undefined;
/**
* Quantity bought during the day
* @member {Number} dayBuyQuantity
*/
PositionData.prototype.dayBuyQuantity = undefined;
/**
* Amount at which the quantity is sold during the day
* @member {Number} daySellValue
*/
PositionData.prototype.daySellValue = undefined;
/**
* Average price at which the day quantity was sold
* @member {Number} daySellPrice
*/
PositionData.prototype.daySellPrice = undefined;
/**
* Amount at which the quantity was sold in the previous session
* @member {Number} overnightSellAmount
*/
PositionData.prototype.overnightSellAmount = undefined;
/**
* Quantity sold short in the previous session
* @member {Number} overnightSellQuantity
*/
PositionData.prototype.overnightSellQuantity = undefined;
/**
* Quantity sold during the day
* @member {Number} daySellQuantity
*/
PositionData.prototype.daySellQuantity = undefined;
/**
* Quantity left after nullifying Day and CF buy quantity towards Day and CF sell quantity
* @member {Number} quantity
*/
PositionData.prototype.quantity = undefined;
/**
* Last traded market price of the instrument
* @member {Number} lastPrice
*/
PositionData.prototype.lastPrice = undefined;
/**
* Day PnL generated against open positions
* @member {Number} unrealised
*/
PositionData.prototype.unrealised = undefined;
/**
* Day PnL generated against closed positions
* @member {Number} realised
*/
PositionData.prototype.realised = undefined;
/**
* Net value of the sold quantities
* @member {Number} sellValue
*/
PositionData.prototype.sellValue = undefined;
/**
* Shows the trading symbol of the instrument
* @member {String} tradingsymbol
*/
PositionData.prototype.tradingsymbol = undefined;
/**
* Shows the trading symbol of the instrument
* @member {String} tradingSymbol
*/
PositionData.prototype.tradingSymbol = undefined;
/**
* Closing price of the instrument from the last trading day
* @member {Number} closePrice
*/
PositionData.prototype.closePrice = undefined;
/**
* Average price at which quantities were bought
* @member {Number} buyPrice
*/
PositionData.prototype.buyPrice = undefined;
/**
* Average price at which quantities were sold
* @member {Number} sellPrice
*/
PositionData.prototype.sellPrice = undefined;