@factset/sdk-formula
Version:
Formula client library for JavaScript
165 lines (157 loc) • 12.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.GetCrossSectionalDataForListResponseWrapper = void 0;
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
var _BatchStatusResponse = _interopRequireDefault(require("../model/BatchStatusResponse"));
var _CrossSectionalRequest = _interopRequireDefault(require("../model/CrossSectionalRequest"));
var _CrossSectionalResponse = _interopRequireDefault(require("../model/CrossSectionalResponse"));
var _ErrorDetail = _interopRequireDefault(require("../model/ErrorDetail"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
* FactSet Formula API
* **FactSet Formula API** FactSet's Formula API is a modern, flexible, formula-based API that enables users to access FactSet's wide range of financial data and content. The API offers two endpoints, one optimized for time-series analysis and one designed for cross-sectional analysis, providing users a simplified interface into FactSet's expansive offering. By providing two endpoints, it allows for the optimization of user workflows, while reducing complexity. Leverage the power and flexibility of the Formula API to - * Pull data from across most content sets that a user has access to in a single request * Include business logic and mathematical operations in request * Submit a dynamic universe in both endpoints * Return the fsymId to easily combine with other FactSet content / products * Set the trading calendar * Define custom display names **Formula API Request Builder** The Formula API Request Builder provides users everything they need to form a Formula API request. In the Request Builder, you can select identifiers, build a universe expression, select FQL or Screening formulas, easily apply business logic and mathematical functions to the FQL or Screening formulas, specify optional parameters, and construct a GET or POST request. The Request Builder eliminates the need to have previous FQL and Screening knowledge and allows you to quickly find your desired data items and form the request. The Formula API Request Builder can be accessed by navigating to [https://developer.factset.com/formula-api-request-builder](https://developer.factset.com/formula-api-request-builder) and logging in using your FactSet.net ID. When using the Request Builder to construct requests for the one of the Formula API's endpoints, be sure to toggle to the correct endpoint at the top of the page. **How to Check the Health and Availability of the Formula API** Please use the below endpoint to check the health and availability of the Formula API. You must be authorized for this API to use the Health endpoint. [https://api.factset.com/formula-api/health](https://api.factset.com/formula-api/health) **How to Programmatically Download API Specification File** You can download the FactSet Formula API Specification File in .yaml. using the \"Download Spec\" button to the right of the version number. This specification can then be used for Codegen to create your own SDKs.
*
* The version of the OpenAPI document: 1.13.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.
*
*/
/**
* CrossSectional service.
* @module api/CrossSectionalApi
*/
class CrossSectionalApi {
/**
* Constructs a new CrossSectionalApi.
* @alias module:api/CrossSectionalApi
* @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;
}
/**
* Retrieve data items (Screening formulas) for a list of identifiers or defined universe.
* The `/cross-sectional` endpoint is closely aligned with FactSet's powerful data retrieval **Screening language** which is optimized for analysis of data items at single point in time for different entities and is extremely efficient for large universes. The `/cross-sectional` endpoint supports Long Running asynchronous requests up to **30 minutes** via the `batch` parameter. *This feature is available to Individual Users subscribed to the Performance Package and Performance Package Plus Performance Tiers and all Production Users. If you are unsure which Performance Tier you are subscribed to or you would like to gain access to the batch capabilities, please contact your FactSet Account Team or \"Report Issue\" above and our support teams can assist.* *** ### Iterated Cross-Sectional Functionality This endpoint supports the ability to automatically iterate through different cross sections over time. The **Iterated Cross-Sectional Functionality (ICSF)** expands the Cross-Sectional endpoint to support retrieving data items for *multiple dates*, allowing users to take advantage of the Screening engine's efficiency even when history is required. Use the parameters `startDate`, `endDate`, and `frequency` in the Cross-Sectional endpoint to provide your desired dates. Specify \"0\" in date argument of the Screening formulas provided in the formulas parameter and/or the universe parameter. Lastly, the Iterated Cross-Sectional Functionality is required to run as a `batch` request. Therefore, the batch parameter must be set to \"Y\". Access to backtesting and batch functionality is required to leverage the Iterated Cross-Sectional Functionality. **When to use ICSF:** The ICSF can offer better performance than Time-Series requests when the date range is relatively small, and so it is recommended to use ICSF if the number of IDs requested is greater than the number of dates. If the number of dates is greater than the number of IDs in the request, it is recommended to use Time-Series. *Note: This is a general rule of thumb and performance may vary depending on the formulas in use.*
* @param {module:model/CrossSectionalRequest} crossSectionalRequest
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/CrossSectionalResponse} and HTTP response
*/
getCrossSectionalDataForListWithHttpInfo(crossSectionalRequest) {
let postBody = crossSectionalRequest;
// verify the required parameter 'crossSectionalRequest' is set
if (crossSectionalRequest === undefined || crossSectionalRequest === null) {
throw new Error("Missing the required parameter 'crossSectionalRequest' when calling getCrossSectionalDataForList");
}
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['FactSetApiKey', 'FactSetOAuth2'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = GetCrossSectionalDataForListResponseWrapperTypeMap;
return this.apiClient.callApi('/cross-sectional', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Retrieve data items (Screening formulas) for a list of identifiers or defined universe.
* The `/cross-sectional` endpoint is closely aligned with FactSet's powerful data retrieval **Screening language** which is optimized for analysis of data items at single point in time for different entities and is extremely efficient for large universes. The `/cross-sectional` endpoint supports Long Running asynchronous requests up to **30 minutes** via the `batch` parameter. *This feature is available to Individual Users subscribed to the Performance Package and Performance Package Plus Performance Tiers and all Production Users. If you are unsure which Performance Tier you are subscribed to or you would like to gain access to the batch capabilities, please contact your FactSet Account Team or \"Report Issue\" above and our support teams can assist.* *** ### Iterated Cross-Sectional Functionality This endpoint supports the ability to automatically iterate through different cross sections over time. The **Iterated Cross-Sectional Functionality (ICSF)** expands the Cross-Sectional endpoint to support retrieving data items for *multiple dates*, allowing users to take advantage of the Screening engine's efficiency even when history is required. Use the parameters `startDate`, `endDate`, and `frequency` in the Cross-Sectional endpoint to provide your desired dates. Specify \"0\" in date argument of the Screening formulas provided in the formulas parameter and/or the universe parameter. Lastly, the Iterated Cross-Sectional Functionality is required to run as a `batch` request. Therefore, the batch parameter must be set to \"Y\". Access to backtesting and batch functionality is required to leverage the Iterated Cross-Sectional Functionality. **When to use ICSF:** The ICSF can offer better performance than Time-Series requests when the date range is relatively small, and so it is recommended to use ICSF if the number of IDs requested is greater than the number of dates. If the number of dates is greater than the number of IDs in the request, it is recommended to use Time-Series. *Note: This is a general rule of thumb and performance may vary depending on the formulas in use.*
* @param {module:model/CrossSectionalRequest} crossSectionalRequest
* @return { Promise.< GetCrossSectionalDataForListResponseWrapper > } a Promise, with data of type {@link GetCrossSectionalDataForListResponseWrapper }
*/
getCrossSectionalDataForList(crossSectionalRequest) {
return this.getCrossSectionalDataForListWithHttpInfo(crossSectionalRequest).then(function (response_and_data) {
return response_and_data.data;
});
}
}
exports.default = CrossSectionalApi;
const GetCrossSectionalDataForListResponseWrapperTypeMap = {
200: _CrossSectionalResponse.default,
202: _BatchStatusResponse.default,
400: _ErrorDetail.default,
401: _ErrorDetail.default,
403: _ErrorDetail.default,
404: _ErrorDetail.default,
405: _ErrorDetail.default,
406: _ErrorDetail.default,
408: _ErrorDetail.default,
413: _ErrorDetail.default,
415: _ErrorDetail.default,
429: _ErrorDetail.default,
500: _ErrorDetail.default,
501: _ErrorDetail.default,
503: _ErrorDetail.default,
_createResponseWrapper(statusCode, response) {
return new GetCrossSectionalDataForListResponseWrapper(statusCode, response);
}
};
/**
* Wrapper to support POST /cross-sectional returning different types
* per status code.
*
* <p>
* Responses:
* <ul>
* <li>200 : {@code CrossSectionalResponse }<br>Gets an array of `Response Objects` for a list of IDs and Screening formulas.</li>
*
* <li>202 : {@code BatchStatusResponse }<br>Batch request has been accepted.</li>
* </ul>
*
* </p>
* Example:
* <pre>{@code
* const response = ...;
* switch (response.statusCode) {
* case 200:
* CrossSectionalResponse data200 = response.getResponse200();
* break;
* case 202:
* BatchStatusResponse data202 = response.getResponse202();
* break;
* }
* }</pre>
*
* @alias module:GetCrossSectionalDataForListResponseWrapper
* @class
*/
class GetCrossSectionalDataForListResponseWrapper {
/**
* @param {number} statusCode
* @param {*} response
*/
constructor(statusCode, response) {
/**
* @type {number}
*/
this.statusCode = statusCode;
/**
* @type {*}
*/
this.response = response;
}
/**
* @returns { CrossSectionalResponse }
*/
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.GetCrossSectionalDataForListResponseWrapper = GetCrossSectionalDataForListResponseWrapper;