@airnub/unusualwhales-api-client
Version:
A client library for interacting with the UnusualWhales API, written in TypeScript
122 lines (121 loc) • 4.28 kB
JavaScript
;
// Copyright (c) 2023 Airnub Technologies LTD. All rights reserved.
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MarketApi = void 0;
class MarketApi {
constructor(axiosInstance) {
this.axiosInstance = axiosInstance;
}
/**
* Market Holidays
* Returns the market holidays.
*/
getMarketHolidays() {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.axiosInstance.get(`/api/market/holidays`, {
params: {},
});
return response.data;
}
catch (error) {
console.error('Error fetching getMarketHolidays:', error);
throw error;
}
});
}
/**
* Market Tide
* Returns the market tide information.
* @param date (Optional)
* @param otmOnly (Optional)
*/
getMarketTide(date, otmOnly) {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.axiosInstance.get(`/api/market/market-tide`, {
params: {
date,
otmOnly
},
});
return response.data;
}
catch (error) {
console.error('Error fetching getMarketTide:', error);
throw error;
}
});
}
/**
* Sector ETFs
* Returns the current trading days statistics for the SPDR sector etfs
*/
getSectorEtfs() {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.axiosInstance.get(`/api/market/sector-etfs`, {
params: {},
});
return response.data;
}
catch (error) {
console.error('Error fetching getSectorEtfs:', error);
throw error;
}
});
}
/**
* Total Options Volume
* Returns the total options volume and premium for all trade executions that happened on a given trading date.
* @param limit (Optional)
*/
getTotalOptionsVolume(limit) {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.axiosInstance.get(`/api/market/total-options-volume`, {
params: {
limit
},
});
return response.data;
}
catch (error) {
console.error('Error fetching getTotalOptionsVolume:', error);
throw error;
}
});
}
/**
* Tickers By Sector
* Returns a list of tickers belonging to the specified sector.
* @param sector (Required)
*/
getTickersBySector(sector) {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.axiosInstance.get(`/api/stock/${sector}/tickers`, {
params: {
sector
},
});
return response.data;
}
catch (error) {
console.error('Error fetching getTickersBySector:', error);
throw error;
}
});
}
}
exports.MarketApi = MarketApi;