upstox-js-sdk
Version:
The official Node Js client for communicating with the Upstox API
528 lines (456 loc) • 20.7 kB
JavaScript
/*
* OpenAPI definition
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: v0
*
* 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.66
*
* Do not edit the class manually.
*
*/
import {ApiClient} from "../ApiClient";
import {AnalyticsResponse} from '../model/AnalyticsResponse';
/**
* Market service.
* @module api/MarketApi
* @version v0
*/
export class MarketApi {
/**
* Constructs a new MarketApi.
* @alias module:api/MarketApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
constructor(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
}
/**
* Callback function to receive the result of the getChangeOiData operation.
* @callback moduleapi/MarketApi~getChangeOiDataCallback
* @param {String} error Error message, if any.
* @param {module:model/AnalyticsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get Change in OI Data
* Fetches change in OI data for the given instrument key, expiry, date and interval.
* @param {Object} instrumentKey Underlying asset instrument key
* @param {Object} expiry Expiry date in YYYY-MM-DD format
* @param {Object} _date Date in YYYY-MM-DD format for which change OI data is required
* @param {Object} interval Number of days for which difference in OI is required
* @param {module:api/MarketApi~getChangeOiDataCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getChangeOiData(instrumentKey, expiry, _date, interval, callback) {
let postBody = null;
// verify the required parameter 'instrumentKey' is set
if (instrumentKey === undefined || instrumentKey === null) {
throw new Error("Missing the required parameter 'instrumentKey' when calling getChangeOiData");
}
// verify the required parameter 'expiry' is set
if (expiry === undefined || expiry === null) {
throw new Error("Missing the required parameter 'expiry' when calling getChangeOiData");
}
// verify the required parameter '_date' is set
if (_date === undefined || _date === null) {
throw new Error("Missing the required parameter '_date' when calling getChangeOiData");
}
// verify the required parameter 'interval' is set
if (interval === undefined || interval === null) {
throw new Error("Missing the required parameter 'interval' when calling getChangeOiData");
}
let pathParams = {
};
let queryParams = {
'instrument_key': instrumentKey,'expiry': expiry,'date': _date,'interval': interval
};
let headerParams = {
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = AnalyticsResponse;
return this.apiClient.callApi(
'/v2/market/change-oi', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getDiiData operation.
* @callback moduleapi/MarketApi~getDiiDataCallback
* @param {String} error Error message, if any.
* @param {module:model/AnalyticsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get DII Data
* Fetches DII activity data for the given interval.
* @param {Object} dataType Data type. Allowed value: NSE_EQ|CASH
* @param {Object} interval Interval. Allowed values: 1D, 1M
* @param {Object} opts Optional parameters
* @param {Object} opts.from Start date in YYYY-MM-DD format (optional)
* @param {module:api/MarketApi~getDiiDataCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getDiiData(dataType, interval, opts, callback) {
opts = opts || {};
let postBody = null;
// verify the required parameter 'dataType' is set
if (dataType === undefined || dataType === null) {
throw new Error("Missing the required parameter 'dataType' when calling getDiiData");
}
// verify the required parameter 'interval' is set
if (interval === undefined || interval === null) {
throw new Error("Missing the required parameter 'interval' when calling getDiiData");
}
let pathParams = {
};
let queryParams = {
'data_type': dataType,'interval': interval,'from': opts['from']
};
let headerParams = {
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = AnalyticsResponse;
return this.apiClient.callApi(
'/v2/market/dii', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getFiiData operation.
* @callback moduleapi/MarketApi~getFiiDataCallback
* @param {String} error Error message, if any.
* @param {module:model/AnalyticsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get FII Data
* Fetches FII activity data for the given data type and interval.
* @param {Object} dataType Data type. Allowed values: NSE_FO|INDEX_FUTURES, NSE_FO|STOCK_FUTURES, NSE_FO|INDEX_OPTIONS, NSE_FO|STOCK_OPTIONS, NSE_EQ|CASH
* @param {Object} interval Interval. Allowed values: 1D, 1M
* @param {Object} opts Optional parameters
* @param {Object} opts.from Start date in YYYY-MM-DD format (optional)
* @param {module:api/MarketApi~getFiiDataCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getFiiData(dataType, interval, opts, callback) {
opts = opts || {};
let postBody = null;
// verify the required parameter 'dataType' is set
if (dataType === undefined || dataType === null) {
throw new Error("Missing the required parameter 'dataType' when calling getFiiData");
}
// verify the required parameter 'interval' is set
if (interval === undefined || interval === null) {
throw new Error("Missing the required parameter 'interval' when calling getFiiData");
}
let pathParams = {
};
let queryParams = {
'data_type': dataType,'interval': interval,'from': opts['from']
};
let headerParams = {
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = AnalyticsResponse;
return this.apiClient.callApi(
'/v2/market/fii', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getMaxPainData operation.
* @callback moduleapi/MarketApi~getMaxPainDataCallback
* @param {String} error Error message, if any.
* @param {module:model/AnalyticsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get Max Pain Data
* Fetches Max Pain data for the given instrument key, expiry, date and bucket interval.
* @param {Object} instrumentKey Underlying asset instrument key
* @param {Object} expiry Expiry date in YYYY-MM-DD format
* @param {Object} _date Date in YYYY-MM-DD format for which Max Pain data is required
* @param {Object} bucketInterval Bucket interval in minutes for the insights list
* @param {module:api/MarketApi~getMaxPainDataCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getMaxPainData(instrumentKey, expiry, _date, bucketInterval, callback) {
let postBody = null;
// verify the required parameter 'instrumentKey' is set
if (instrumentKey === undefined || instrumentKey === null) {
throw new Error("Missing the required parameter 'instrumentKey' when calling getMaxPainData");
}
// verify the required parameter 'expiry' is set
if (expiry === undefined || expiry === null) {
throw new Error("Missing the required parameter 'expiry' when calling getMaxPainData");
}
// verify the required parameter '_date' is set
if (_date === undefined || _date === null) {
throw new Error("Missing the required parameter '_date' when calling getMaxPainData");
}
// verify the required parameter 'bucketInterval' is set
if (bucketInterval === undefined || bucketInterval === null) {
throw new Error("Missing the required parameter 'bucketInterval' when calling getMaxPainData");
}
let pathParams = {
};
let queryParams = {
'instrument_key': instrumentKey,'expiry': expiry,'date': _date,'bucket_interval': bucketInterval
};
let headerParams = {
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = AnalyticsResponse;
return this.apiClient.callApi(
'/v2/market/max-pain', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getOiData operation.
* @callback moduleapi/MarketApi~getOiDataCallback
* @param {String} error Error message, if any.
* @param {module:model/AnalyticsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get OI Data
* Fetches OI data for the given instrument key, expiry and date.
* @param {Object} instrumentKey Underlying asset instrument key
* @param {Object} expiry Expiry date in YYYY-MM-DD format
* @param {Object} _date Date in YYYY-MM-DD format for which OI data is required
* @param {module:api/MarketApi~getOiDataCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getOiData(instrumentKey, expiry, _date, callback) {
let postBody = null;
// verify the required parameter 'instrumentKey' is set
if (instrumentKey === undefined || instrumentKey === null) {
throw new Error("Missing the required parameter 'instrumentKey' when calling getOiData");
}
// verify the required parameter 'expiry' is set
if (expiry === undefined || expiry === null) {
throw new Error("Missing the required parameter 'expiry' when calling getOiData");
}
// verify the required parameter '_date' is set
if (_date === undefined || _date === null) {
throw new Error("Missing the required parameter '_date' when calling getOiData");
}
let pathParams = {
};
let queryParams = {
'instrument_key': instrumentKey,'expiry': expiry,'date': _date
};
let headerParams = {
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = AnalyticsResponse;
return this.apiClient.callApi(
'/v2/market/oi', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getPcrData operation.
* @callback moduleapi/MarketApi~getPcrDataCallback
* @param {String} error Error message, if any.
* @param {module:model/AnalyticsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get PCR Data
* Fetches PCR (Put-Call Ratio) data for the given instrument key, expiry, date and bucket interval.
* @param {Object} instrumentKey Underlying asset instrument key
* @param {Object} expiry Expiry date in YYYY-MM-DD format
* @param {Object} _date Date in YYYY-MM-DD format for which PCR data is required
* @param {Object} bucketInterval Bucket interval in minutes for the insights list
* @param {module:api/MarketApi~getPcrDataCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getPcrData(instrumentKey, expiry, _date, bucketInterval, callback) {
let postBody = null;
// verify the required parameter 'instrumentKey' is set
if (instrumentKey === undefined || instrumentKey === null) {
throw new Error("Missing the required parameter 'instrumentKey' when calling getPcrData");
}
// verify the required parameter 'expiry' is set
if (expiry === undefined || expiry === null) {
throw new Error("Missing the required parameter 'expiry' when calling getPcrData");
}
// verify the required parameter '_date' is set
if (_date === undefined || _date === null) {
throw new Error("Missing the required parameter '_date' when calling getPcrData");
}
// verify the required parameter 'bucketInterval' is set
if (bucketInterval === undefined || bucketInterval === null) {
throw new Error("Missing the required parameter 'bucketInterval' when calling getPcrData");
}
let pathParams = {
};
let queryParams = {
'instrument_key': instrumentKey,'expiry': expiry,'date': _date,'bucket_interval': bucketInterval
};
let headerParams = {
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = AnalyticsResponse;
return this.apiClient.callApi(
'/v2/market/pcr', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getSmartlistFutures operation.
* @callback moduleapi/MarketApi~getSmartlistFuturesCallback
* @param {String} error Error message, if any.
* @param {module:model/AnalyticsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get Smartlist Futures
* Fetches the smartlist of futures for the given asset type and category.
* @param {Object} opts Optional parameters
* @param {Object} opts.assetType Asset type. Allowed values: INDEX, STOCK, COMMODITY
* @param {Object} opts.category Category. Allowed values: TOP_TRADED, MOST_ACTIVE, OI_GAINERS, OI_LOSERS, PRICE_GAINERS, PRICE_LOSERS, PREMIUM, DISCOUNT (COMMODITY supports only: TOP_TRADED, MOST_ACTIVE, OI_GAINERS, OI_LOSERS)
* @param {Object} opts.pageNumber Page number (optional, 1-indexed)
* @param {Object} opts.pageSize Page size (optional, max 50)
* @param {module:api/MarketApi~getSmartlistFuturesCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getSmartlistFutures(opts, callback) {
opts = opts || {};
let postBody = null;
let pathParams = {
};
let queryParams = {
'asset_type': opts['assetType'],'category': opts['category'],'page_number': opts['pageNumber'],'page_size': opts['pageSize']
};
let headerParams = {
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = AnalyticsResponse;
return this.apiClient.callApi(
'/v2/market/smartlist/futures', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getSmartlistMtf operation.
* @callback moduleapi/MarketApi~getSmartlistMtfCallback
* @param {String} error Error message, if any.
* @param {module:model/AnalyticsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get Smartlist MTF
* Fetches the smartlist of MTF (Margin Trade Funding) stocks. Prices are enriched with live LTP data.
* @param {Object} opts Optional parameters
* @param {Object} opts.pageNumber Page number (optional, 1-indexed)
* @param {Object} opts.pageSize Page size (optional, max 50)
* @param {module:api/MarketApi~getSmartlistMtfCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getSmartlistMtf(opts, callback) {
opts = opts || {};
let postBody = null;
let pathParams = {
};
let queryParams = {
'page_number': opts['pageNumber'],'page_size': opts['pageSize']
};
let headerParams = {
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = AnalyticsResponse;
return this.apiClient.callApi(
'/v2/market/smartlist/mtf', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getSmartlistOptions operation.
* @callback moduleapi/MarketApi~getSmartlistOptionsCallback
* @param {String} error Error message, if any.
* @param {module:model/AnalyticsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get Smartlist Options
* Fetches the smartlist of options for the given asset type and category.
* @param {Object} opts Optional parameters
* @param {Object} opts.assetType Asset type. Allowed values: INDEX, STOCK, COMMODITY
* @param {Object} opts.category Category. Allowed values: TOP_TRADED, MOST_ACTIVE, OI_GAINERS, OI_LOSERS, PRICE_GAINERS, PRICE_LOSERS, IV_GAINERS, IV_LOSERS, UNDER_5000, UNDER_10000 (COMMODITY supports only: TOP_TRADED, MOST_ACTIVE, OI_GAINERS, OI_LOSERS)
* @param {Object} opts.pageNumber Page number (optional, 1-indexed)
* @param {Object} opts.pageSize Page size (optional, max 50)
* @param {module:api/MarketApi~getSmartlistOptionsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getSmartlistOptions(opts, callback) {
opts = opts || {};
let postBody = null;
let pathParams = {
};
let queryParams = {
'asset_type': opts['assetType'],'category': opts['category'],'page_number': opts['pageNumber'],'page_size': opts['pageSize']
};
let headerParams = {
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = AnalyticsResponse;
return this.apiClient.callApi(
'/v2/market/smartlist/options', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}