@factset/sdk-factsetglobalprices
Version:
FactSet Global Prices client library for JavaScript
308 lines (294 loc) • 18.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.GetSecurityPricesForListResponseWrapper = exports.GetGPDPricesResponseWrapper = void 0;
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
var _BatchStatusResponse = _interopRequireDefault(require("../model/BatchStatusResponse"));
var _ErrorResponse = _interopRequireDefault(require("../model/ErrorResponse"));
var _GlobalPricesRequest = _interopRequireDefault(require("../model/GlobalPricesRequest"));
var _GlobalPricesResponse = _interopRequireDefault(require("../model/GlobalPricesResponse"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
* FactSet Global Prices API
* The FactSet Global Prices API provides end of day market pricing content using cloud and microservices technology, encompassing both pricing as well as corporate actions and events data.</p>
*
* The version of the OpenAPI document: 1.11.0
* Contact: api@factset.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*
*/
/**
* Prices service.
* @module api/PricesApi
*/
class PricesApi {
/**
* Constructs a new PricesApi.
* @alias module:api/PricesApi
* @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.default.instance;
}
/**
* Gets end-of-day Open, High, Low, Close for a list of securities.
* Gets security prices', Open, High, Low, Close, Volume, VWAP, Trade Count, and Turn Over for a specified list of securities, date range, currency, and adjustment factors.
* @param {Array.<String>} ids The requested list of security identifiers. Accepted ID types include Market Tickers, SEDOL, ISINs, CUSIPs, or FactSet Permanent IDs. **IDs limit** = 500 per non-batch request / 2000 per batch request for a single day and 50 per multi-day request for both batch and non-batch. The number of unique currencies present in the requested IDs is limited to 50 per request. Make note, GET Method URL request lines are also limited to a total length of 8192 bytes (8KB). In cases where the service allows for thousands of IDs, which may lead to exceeding this request line limit of 8KB, it's advised for any requests with large request lines to be requested through the respective \"POST\" method.
* @param {String} startDate The start date requested for a given date range in **YYYY-MM-DD** format. The input start date must be before the input end date. Future dates (T+1) are not accepted in this endpoint.
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.fields Request available pricing data fields to be included in the response. Default is all fields. All responses will include the _fsymId_, _date_, and _currency_ fields. |field|description| |---|---| |price|Closing Price| |priceOpen|Opening Price| |priceHigh|High Price| |priceLow|Low Price| |volume|Volume| |turnover|Total Trade Value for the Day| |tradeCount|Number of Trades| |vwap|Volume Weighted Average Price|
* @param {String} opts.endDate The end date requested for a given date range in **YYYY-MM-DD** format. The input end date must be after the input start date. Future dates (T+1) are not accepted in this endpoint.
* @param {module:model/String} opts.frequency Controls the display frequency of the data returned. * **D** = Daily * **AD** = Actual Daily * **W** = Weekly, based on the last day of the week of the start date. * **M** = Monthly, based on the last trading day of the month. * **AM** = Monthly, based on the start date (e.g., if the start date is June 16, data is displayed for June 16, May 16, April 16 etc.). * **AQ** = Actual Quarterly * **CQ** = Quarterly based on the last trading day of the calendar quarter (March, June, September, or December). * **ASA** = Actual Semi-annual * **CSA** = Calendar Semi-annual * **AY** = Actual Annual, based on the start date. * **CY** = Calendar Annual, based on the last trading day of the calendar year. (default to 'D')
* @param {module:model/String} opts.calendar Calendar of data returned. SEVENDAY includes weekends. (default to 'FIVEDAY')
* @param {String} opts.currency Currency code for adjusting prices. Default is Local. For a list of currency ISO codes, visit [Online Assistant Page 1470](https://oa.apps.factset.com/pages/1470). (default to 'LOCAL')
* @param {module:model/String} opts.adjust Controls the split and spinoff adjustments for the prices. * **SPLIT** = Split ONLY Adjusted. This is used by default. * **SPLIT_SPINOFF** = Splits and Spinoff Adjusted. * **DIV_SPIN_SPLITS** = Dividend adjustments, Spinoff, and Splits combined. * **UNSPLIT** = No Adjustments. (default to 'SPLIT')
* @param {Number} opts.precision Specifies the number of decimal places for price fields in the response. (default to 16)
* @param {module:model/String} opts.batch Enables the ability to asynchronously \"batch\" the request, supporting a long-running request for up to 20 minutes. Upon requesting batch=Y, the service will respond with an HTTP Status Code of 202. Once a batch request is submitted, use batch status to see if the job has been completed. Once completed, retrieve the results of the request via batch-result. For single-day requests, the IDs limit is 500 for non-batch and 2000 for batch. For multi-day requests, the limit is 50 IDs for both batch and non-batch. Limits on query string via GET method still apply. It's advised to submit large lists of IDs via POST method. <B>Please note that the number of unique currencies present in the requested IDs is limited to 50 per request.</B> (default to 'N')
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GlobalPricesResponse} and HTTP response
*/
getGPDPricesWithHttpInfo(ids, startDate, opts) {
opts = opts || {};
let postBody = null;
// verify the required parameter 'ids' is set
if (ids === undefined || ids === null) {
throw new Error("Missing the required parameter 'ids' when calling getGPDPrices");
}
// verify the required parameter 'startDate' is set
if (startDate === undefined || startDate === null) {
throw new Error("Missing the required parameter 'startDate' when calling getGPDPrices");
}
let pathParams = {};
let queryParams = {
'ids': this.apiClient.buildCollectionParam(ids, 'csv'),
'fields': this.apiClient.buildCollectionParam(opts['fields'], 'csv'),
'startDate': startDate,
'endDate': opts['endDate'],
'frequency': opts['frequency'],
'calendar': opts['calendar'],
'currency': opts['currency'],
'adjust': opts['adjust'],
'precision': opts['precision'],
'batch': opts['batch']
};
let headerParams = {};
let formParams = {};
let authNames = ['FactSetApiKey', 'FactSetOAuth2'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = GetGPDPricesResponseWrapperTypeMap;
return this.apiClient.callApi('/factset-global-prices/v1/prices', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Gets end-of-day Open, High, Low, Close for a list of securities.
* Gets security prices', Open, High, Low, Close, Volume, VWAP, Trade Count, and Turn Over for a specified list of securities, date range, currency, and adjustment factors.
* @param {Array.<String>} ids The requested list of security identifiers. Accepted ID types include Market Tickers, SEDOL, ISINs, CUSIPs, or FactSet Permanent IDs. **IDs limit** = 500 per non-batch request / 2000 per batch request for a single day and 50 per multi-day request for both batch and non-batch. The number of unique currencies present in the requested IDs is limited to 50 per request. Make note, GET Method URL request lines are also limited to a total length of 8192 bytes (8KB). In cases where the service allows for thousands of IDs, which may lead to exceeding this request line limit of 8KB, it's advised for any requests with large request lines to be requested through the respective \"POST\" method.
* @param {String} startDate The start date requested for a given date range in **YYYY-MM-DD** format. The input start date must be before the input end date. Future dates (T+1) are not accepted in this endpoint.
* @param {Object} opts Optional parameters
* @param {Array.<String>} opts.fields Request available pricing data fields to be included in the response. Default is all fields. All responses will include the _fsymId_, _date_, and _currency_ fields. |field|description| |---|---| |price|Closing Price| |priceOpen|Opening Price| |priceHigh|High Price| |priceLow|Low Price| |volume|Volume| |turnover|Total Trade Value for the Day| |tradeCount|Number of Trades| |vwap|Volume Weighted Average Price|
* @param {String} opts.endDate The end date requested for a given date range in **YYYY-MM-DD** format. The input end date must be after the input start date. Future dates (T+1) are not accepted in this endpoint.
* @param {module:model/String} opts.frequency Controls the display frequency of the data returned. * **D** = Daily * **AD** = Actual Daily * **W** = Weekly, based on the last day of the week of the start date. * **M** = Monthly, based on the last trading day of the month. * **AM** = Monthly, based on the start date (e.g., if the start date is June 16, data is displayed for June 16, May 16, April 16 etc.). * **AQ** = Actual Quarterly * **CQ** = Quarterly based on the last trading day of the calendar quarter (March, June, September, or December). * **ASA** = Actual Semi-annual * **CSA** = Calendar Semi-annual * **AY** = Actual Annual, based on the start date. * **CY** = Calendar Annual, based on the last trading day of the calendar year. (default to 'D')
* @param {module:model/String} opts.calendar Calendar of data returned. SEVENDAY includes weekends. (default to 'FIVEDAY')
* @param {String} opts.currency Currency code for adjusting prices. Default is Local. For a list of currency ISO codes, visit [Online Assistant Page 1470](https://oa.apps.factset.com/pages/1470). (default to 'LOCAL')
* @param {module:model/String} opts.adjust Controls the split and spinoff adjustments for the prices. * **SPLIT** = Split ONLY Adjusted. This is used by default. * **SPLIT_SPINOFF** = Splits and Spinoff Adjusted. * **DIV_SPIN_SPLITS** = Dividend adjustments, Spinoff, and Splits combined. * **UNSPLIT** = No Adjustments. (default to 'SPLIT')
* @param {Number} opts.precision Specifies the number of decimal places for price fields in the response. (default to 16)
* @param {module:model/String} opts.batch Enables the ability to asynchronously \"batch\" the request, supporting a long-running request for up to 20 minutes. Upon requesting batch=Y, the service will respond with an HTTP Status Code of 202. Once a batch request is submitted, use batch status to see if the job has been completed. Once completed, retrieve the results of the request via batch-result. For single-day requests, the IDs limit is 500 for non-batch and 2000 for batch. For multi-day requests, the limit is 50 IDs for both batch and non-batch. Limits on query string via GET method still apply. It's advised to submit large lists of IDs via POST method. <B>Please note that the number of unique currencies present in the requested IDs is limited to 50 per request.</B> (default to 'N')
* @return { Promise.< GetGPDPricesResponseWrapper > } a Promise, with data of type {@link GetGPDPricesResponseWrapper }
*/
getGPDPrices(ids, startDate, opts) {
return this.getGPDPricesWithHttpInfo(ids, startDate, opts).then(function (response_and_data) {
return response_and_data.data;
});
}
/**
* Requests end-of-day Open, High, Low, Close for a large list of securities.
* Gets security prices', Open, High, Low, Close, Volume, VWAP, Trade Count, and Turn Over for a specified list of securities, date range, currency, and adjustment factors.
* @param {module:model/GlobalPricesRequest} globalPricesRequest Request object for `Prices`.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GlobalPricesResponse} and HTTP response
*/
getSecurityPricesForListWithHttpInfo(globalPricesRequest) {
let postBody = globalPricesRequest;
// verify the required parameter 'globalPricesRequest' is set
if (globalPricesRequest === undefined || globalPricesRequest === null) {
throw new Error("Missing the required parameter 'globalPricesRequest' when calling getSecurityPricesForList");
}
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['FactSetApiKey', 'FactSetOAuth2'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = GetSecurityPricesForListResponseWrapperTypeMap;
return this.apiClient.callApi('/factset-global-prices/v1/prices', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Requests end-of-day Open, High, Low, Close for a large list of securities.
* Gets security prices', Open, High, Low, Close, Volume, VWAP, Trade Count, and Turn Over for a specified list of securities, date range, currency, and adjustment factors.
* @param {module:model/GlobalPricesRequest} globalPricesRequest Request object for `Prices`.
* @return { Promise.< GetSecurityPricesForListResponseWrapper > } a Promise, with data of type {@link GetSecurityPricesForListResponseWrapper }
*/
getSecurityPricesForList(globalPricesRequest) {
return this.getSecurityPricesForListWithHttpInfo(globalPricesRequest).then(function (response_and_data) {
return response_and_data.data;
});
}
}
exports.default = PricesApi;
const GetGPDPricesResponseWrapperTypeMap = {
200: _GlobalPricesResponse.default,
202: _BatchStatusResponse.default,
400: _ErrorResponse.default,
401: _ErrorResponse.default,
403: _ErrorResponse.default,
415: _ErrorResponse.default,
500: _ErrorResponse.default,
_createResponseWrapper(statusCode, response) {
return new GetGPDPricesResponseWrapper(statusCode, response);
}
};
const GetSecurityPricesForListResponseWrapperTypeMap = {
200: _GlobalPricesResponse.default,
202: _BatchStatusResponse.default,
400: _ErrorResponse.default,
401: _ErrorResponse.default,
403: _ErrorResponse.default,
415: _ErrorResponse.default,
500: _ErrorResponse.default,
_createResponseWrapper(statusCode, response) {
return new GetSecurityPricesForListResponseWrapper(statusCode, response);
}
};
/**
* Wrapper to support GET /factset-global-prices/v1/prices returning different types
* per status code.
*
* <p>
* Responses:
* <ul>
* <li>200 : {@code GlobalPricesResponse }<br>Array of Price Objects</li>
*
* <li>202 : {@code BatchStatusResponse }<br>Batch request has been accepted.</li>
* </ul>
*
* </p>
* Example:
* <pre>{@code
* const response = ...;
* switch (response.statusCode) {
* case 200:
* GlobalPricesResponse data200 = response.getResponse200();
* break;
* case 202:
* BatchStatusResponse data202 = response.getResponse202();
* break;
* }
* }</pre>
*
* @alias module:GetGPDPricesResponseWrapper
* @class
*/
class GetGPDPricesResponseWrapper {
/**
* @param {number} statusCode
* @param {*} response
*/
constructor(statusCode, response) {
/**
* @type {number}
*/
this.statusCode = statusCode;
/**
* @type {*}
*/
this.response = response;
}
/**
* @returns { GlobalPricesResponse }
*/
getResponse200() {
if (this.statusCode !== 200) {
throw new Error("Invalid response getter called. getResponse200 can't return a " + this.statusCode + " response");
}
return this.response;
}
/**
* @returns { BatchStatusResponse }
*/
getResponse202() {
if (this.statusCode !== 202) {
throw new Error("Invalid response getter called. getResponse202 can't return a " + this.statusCode + " response");
}
return this.response;
}
}
/**
* Wrapper to support POST /factset-global-prices/v1/prices returning different types
* per status code.
*
* <p>
* Responses:
* <ul>
* <li>200 : {@code GlobalPricesResponse }<br>Array of security prices</li>
*
* <li>202 : {@code BatchStatusResponse }<br>Batch request has been accepted.</li>
* </ul>
*
* </p>
* Example:
* <pre>{@code
* const response = ...;
* switch (response.statusCode) {
* case 200:
* GlobalPricesResponse data200 = response.getResponse200();
* break;
* case 202:
* BatchStatusResponse data202 = response.getResponse202();
* break;
* }
* }</pre>
*
* @alias module:GetSecurityPricesForListResponseWrapper
* @class
*/
exports.GetGPDPricesResponseWrapper = GetGPDPricesResponseWrapper;
class GetSecurityPricesForListResponseWrapper {
/**
* @param {number} statusCode
* @param {*} response
*/
constructor(statusCode, response) {
/**
* @type {number}
*/
this.statusCode = statusCode;
/**
* @type {*}
*/
this.response = response;
}
/**
* @returns { GlobalPricesResponse }
*/
getResponse200() {
if (this.statusCode !== 200) {
throw new Error("Invalid response getter called. getResponse200 can't return a " + this.statusCode + " response");
}
return this.response;
}
/**
* @returns { BatchStatusResponse }
*/
getResponse202() {
if (this.statusCode !== 202) {
throw new Error("Invalid response getter called. getResponse202 can't return a " + this.statusCode + " response");
}
return this.response;
}
}
exports.GetSecurityPricesForListResponseWrapper = GetSecurityPricesForListResponseWrapper;