polygon.io
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -9,3 +9,3 @@ export * from "./rest"; | ||
} | ||
export declare const polygonClient: (apiKey: string) => IPolygonClient; | ||
export declare const polygonClient: (apiKey: string, restApiBase?: string, websocketApiBase?: string) => IPolygonClient; | ||
export default polygonClient; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./rest")); | ||
__export(require("./websockets")); | ||
exports.polygonClient = void 0; | ||
__exportStar(require("./rest"), exports); | ||
__exportStar(require("./websockets"), exports); | ||
const rest_1 = require("./rest"); | ||
const websockets_1 = require("./websockets"); | ||
exports.polygonClient = (apiKey) => ({ | ||
rest: rest_1.default(apiKey), | ||
websockets: websockets_1.default(apiKey) | ||
const polygonClient = (apiKey, restApiBase = "https://api.polygon.io", websocketApiBase = "wss://socket.polygon.io") => ({ | ||
rest: rest_1.default(apiKey, restApiBase), | ||
websockets: websockets_1.default(apiKey, websocketApiBase) | ||
}); | ||
exports.polygonClient = polygonClient; | ||
exports.default = exports.polygonClient; |
import { IAggregateQuery, IAggResponseFormatted } from "../stocks/aggregates"; | ||
export declare const cryptoPreviousClose: (apiKey: string, ticker: string, query?: IAggregateQuery) => Promise<IAggResponseFormatted>; | ||
export declare const cryptoAggregates: (apiKey: string, ticker: string, multiplier: number, timespan: string, from: string, to: string, query?: IAggregateQuery) => Promise<IAggResponseFormatted>; | ||
export declare const cryptoGroupedDaily: (apiKey: string, locale: string, market: string, date: string, query?: IAggregateQuery) => Promise<IAggResponseFormatted>; | ||
export declare const cryptoPreviousClose: (apiKey: string, ticker: string, query?: IAggregateQuery, apiBase?: string) => Promise<IAggResponseFormatted>; | ||
export declare const cryptoAggregates: (apiKey: string, ticker: string, multiplier: number, timespan: string, from: string, to: string, query?: IAggregateQuery, apiBase?: string) => Promise<IAggResponseFormatted>; | ||
export declare const cryptoGroupedDaily: (apiKey: string, locale: string, market: string, date: string, query?: IAggregateQuery, apiBase?: string) => Promise<IAggResponseFormatted>; |
@@ -12,15 +12,19 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cryptoGroupedDaily = exports.cryptoAggregates = exports.cryptoPreviousClose = void 0; | ||
const request_1 = require("../transport/request"); | ||
const aggregates_1 = require("../stocks/aggregates"); | ||
// CF: https://polygon.io/docs/#!/Crypto/get_v2_aggs_ticker_ticker_prev | ||
exports.cryptoPreviousClose = (apiKey, ticker, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query)); | ||
const cryptoPreviousClose = (apiKey, ticker, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query, apiBase)); | ||
}); | ||
exports.cryptoPreviousClose = cryptoPreviousClose; | ||
// CF: https://polygon.io/docs/#!/Crypto/get_v2_aggs_ticker_ticker_range_multiplier_timespan_from_to | ||
exports.cryptoAggregates = (apiKey, ticker, multiplier, timespan, from, to, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/range/${multiplier}/${timespan}/${from}/${to}`, apiKey, query)); | ||
const cryptoAggregates = (apiKey, ticker, multiplier, timespan, from, to, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/range/${multiplier}/${timespan}/${from}/${to}`, apiKey, query, apiBase)); | ||
}); | ||
exports.cryptoAggregates = cryptoAggregates; | ||
// CF: https://polygon.io/docs/#!/Crypto/get_v2_aggs_grouped_locale_locale_market_market_date | ||
exports.cryptoGroupedDaily = (apiKey, locale, market = "CRYPTO", date, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/grouped/locale/${locale}/market/${market}/${date}`, apiKey, query)); | ||
const cryptoGroupedDaily = (apiKey, locale, market = "CRYPTO", date, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/grouped/locale/${locale}/market/${market}/${date}`, apiKey, query, apiBase)); | ||
}); | ||
exports.cryptoGroupedDaily = cryptoGroupedDaily; |
@@ -8,2 +8,2 @@ export interface ICryptoExchanges { | ||
} | ||
export declare const cryptoExchanges: (apiKey: string) => Promise<ICryptoExchanges[]>; | ||
export declare const cryptoExchanges: (apiKey: string, apiBase?: string) => Promise<ICryptoExchanges[]>; |
"use strict"; | ||
//CF: https://polygon.io/docs/#!/Crypto/get_v1_meta_crypto_exchanges | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cryptoExchanges = void 0; | ||
const request_1 = require("../transport/request"); | ||
exports.cryptoExchanges = (apiKey) => request_1.get(`/v1/meta/crypto-exchanges`, apiKey); | ||
const cryptoExchanges = (apiKey, apiBase) => request_1.get(`/v1/meta/crypto-exchanges`, apiKey, undefined, apiBase); | ||
exports.cryptoExchanges = cryptoExchanges; |
import { ICryptoDailyOpenCloseFormatted } from "./ICryptoTickJson"; | ||
export declare const cryptoDailyOpenClose: (apiKey: string, from: string, to: string, date: string) => Promise<ICryptoDailyOpenCloseFormatted>; | ||
export declare const cryptoDailyOpenClose: (apiKey: string, from: string, to: string, date: string, apiBase?: string) => Promise<ICryptoDailyOpenCloseFormatted>; |
@@ -12,7 +12,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cryptoDailyOpenClose = void 0; | ||
const request_1 = require("../transport/request"); | ||
const ICryptoTickJson_1 = require("./ICryptoTickJson"); | ||
// CF: https://polygon.io/docs/#!/Crypto/get_v1_open_close_crypto_from_to_date | ||
exports.cryptoDailyOpenClose = (apiKey, from, to, date) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v1/open-close/crypto/${from}/${to}/${date}`, apiKey); | ||
const cryptoDailyOpenClose = (apiKey, from, to, date, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v1/open-close/crypto/${from}/${to}/${date}`, apiKey, undefined, apiBase); | ||
const data = { | ||
@@ -33,1 +34,2 @@ symbol: raw.symbol, | ||
}); | ||
exports.cryptoDailyOpenClose = cryptoDailyOpenClose; |
@@ -35,2 +35,2 @@ import { IPolygonQuery } from "../transport/request"; | ||
} | ||
export declare const historicCryptoTrades: (apiKey: string, from: string, to: string, date: string, query?: IHistoricCryptoTradeQuery) => Promise<IHistoricCryptoTradeFormatted>; | ||
export declare const historicCryptoTrades: (apiKey: string, from: string, to: string, date: string, query?: IHistoricCryptoTradeQuery, apiBase?: string) => Promise<IHistoricCryptoTradeFormatted>; |
@@ -12,7 +12,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.historicCryptoTrades = void 0; | ||
// CF: https://polygon.io/docs/#!/Crypto/get_v1_historic_crypto_from_to_date | ||
const request_1 = require("../transport/request"); | ||
const ICryptoTickJson_1 = require("./ICryptoTickJson"); | ||
exports.historicCryptoTrades = (apiKey, from, to, date, query = { limit: 100 }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v1/historic/crypto/${from}/${to}/${date}`, apiKey, query); | ||
const historicCryptoTrades = (apiKey, from, to, date, query = { limit: 100 }, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v1/historic/crypto/${from}/${to}/${date}`, apiKey, query, apiBase); | ||
return { | ||
@@ -27,1 +28,2 @@ day: raw.day, | ||
}); | ||
exports.historicCryptoTrades = historicCryptoTrades; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.formatICryptoTickJsonRaw = (trade) => { | ||
exports.formatICryptoTickJsonRaw = void 0; | ||
const formatICryptoTickJsonRaw = (trade) => { | ||
return Object.assign(Object.assign({}, trade), { price: trade.p, size: trade.s, exchange: trade.x, conditions: trade.c, timestamp: trade.t }); | ||
}; | ||
exports.formatICryptoTickJsonRaw = formatICryptoTickJsonRaw; |
@@ -26,3 +26,3 @@ import { ICryptoExchanges } from "./cryptoExchanges"; | ||
} | ||
export declare const cryptoClient: (apiKey: any) => ICryptoClient; | ||
export declare const cryptoClient: (apiKey: any, apiBase?: string) => ICryptoClient; | ||
export default cryptoClient; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cryptoClient = void 0; | ||
const request_1 = require("../transport/request"); | ||
@@ -10,17 +11,18 @@ const dailyOpenClose_1 = require("./dailyOpenClose"); | ||
const historicCryptoTrades_1 = require("./historicCryptoTrades"); | ||
exports.cryptoClient = (apiKey) => ({ | ||
dailyOpenClose: request_1.auth(apiKey, dailyOpenClose_1.cryptoDailyOpenClose), | ||
exchanges: request_1.auth(apiKey, cryptoExchanges_1.cryptoExchanges), | ||
lastTradeForPair: request_1.auth(apiKey, lastTradeForACryptoPair_1.lastTradeForCryptoPair), | ||
historicTrades: request_1.auth(apiKey, historicCryptoTrades_1.historicCryptoTrades), | ||
const cryptoClient = (apiKey, apiBase) => ({ | ||
dailyOpenClose: request_1.auth(apiKey, dailyOpenClose_1.cryptoDailyOpenClose, apiBase), | ||
exchanges: request_1.auth(apiKey, cryptoExchanges_1.cryptoExchanges, apiBase), | ||
lastTradeForPair: request_1.auth(apiKey, lastTradeForACryptoPair_1.lastTradeForCryptoPair, apiBase), | ||
historicTrades: request_1.auth(apiKey, historicCryptoTrades_1.historicCryptoTrades, apiBase), | ||
// snapshots | ||
snapshotSingleTicker: request_1.auth(apiKey, snapshots_1.cryptoSnapshotSingleTicker), | ||
snapshotAllTickers: request_1.auth(apiKey, snapshots_1.cryptoSnapshotAllTickers), | ||
snapshotGainersLosers: request_1.auth(apiKey, snapshots_1.cryptoSnapshotGainersLosers), | ||
snapshotSingleTickerFullBook: request_1.auth(apiKey, snapshots_1.cryptoSnapshotSingleTickerFullBook), | ||
snapshotSingleTicker: request_1.auth(apiKey, snapshots_1.cryptoSnapshotSingleTicker, apiBase), | ||
snapshotAllTickers: request_1.auth(apiKey, snapshots_1.cryptoSnapshotAllTickers, apiBase), | ||
snapshotGainersLosers: request_1.auth(apiKey, snapshots_1.cryptoSnapshotGainersLosers, apiBase), | ||
snapshotSingleTickerFullBook: request_1.auth(apiKey, snapshots_1.cryptoSnapshotSingleTickerFullBook, apiBase), | ||
// aggregates | ||
previousClose: request_1.auth(apiKey, aggregates_1.cryptoPreviousClose), | ||
aggregates: request_1.auth(apiKey, aggregates_1.cryptoAggregates), | ||
groupedDaily: request_1.auth(apiKey, aggregates_1.cryptoGroupedDaily) | ||
previousClose: request_1.auth(apiKey, aggregates_1.cryptoPreviousClose, apiBase), | ||
aggregates: request_1.auth(apiKey, aggregates_1.cryptoAggregates, apiBase), | ||
groupedDaily: request_1.auth(apiKey, aggregates_1.cryptoGroupedDaily, apiBase) | ||
}); | ||
exports.cryptoClient = cryptoClient; | ||
exports.default = exports.cryptoClient; |
@@ -18,2 +18,2 @@ export interface ICryptoTick { | ||
} | ||
export declare const lastTradeForCryptoPair: (apiKey: string, from: string, to: string) => Promise<ILastTradeForACryptoPair>; | ||
export declare const lastTradeForCryptoPair: (apiKey: string, from: string, to: string, apiBase?: string) => Promise<ILastTradeForACryptoPair>; |
"use strict"; | ||
// CF: https://polygon.io/docs/#!/Crypto/get_v1_last_crypto_from_to | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lastTradeForCryptoPair = void 0; | ||
const request_1 = require("../transport/request"); | ||
exports.lastTradeForCryptoPair = (apiKey, from, to) => request_1.get(`/v1/last/crypto/${from}/${to}`, apiKey); | ||
const lastTradeForCryptoPair = (apiKey, from, to, apiBase) => request_1.get(`/v1/last/crypto/${from}/${to}`, apiKey, undefined, apiBase); | ||
exports.lastTradeForCryptoPair = lastTradeForCryptoPair; |
@@ -32,5 +32,5 @@ import { ICryptoTickJsonFormatted } from "./ICryptoTickJson"; | ||
} | ||
export declare const cryptoSnapshotAllTickers: (apiKey: string) => Promise<ICryptoSnapshotAllTickersFormatted>; | ||
export declare const cryptoSnapshotSingleTicker: (apiKey: string, ticker: string) => Promise<ICryptoSnapshotSingleTickerFormatted>; | ||
export declare const cryptoSnapshotGainersLosers: (apiKey: string, direction?: string) => Promise<ICryptoSnapshotAllTickersFormatted>; | ||
export declare const cryptoSnapshotAllTickers: (apiKey: string, apiBase?: string) => Promise<ICryptoSnapshotAllTickersFormatted>; | ||
export declare const cryptoSnapshotSingleTicker: (apiKey: string, ticker: string, apiBase?: string) => Promise<ICryptoSnapshotSingleTickerFormatted>; | ||
export declare const cryptoSnapshotGainersLosers: (apiKey: string, direction?: string, apiBase?: string) => Promise<ICryptoSnapshotAllTickersFormatted>; | ||
export interface ICryptoSnapshotBookItemFormatted { | ||
@@ -55,2 +55,2 @@ p: number; | ||
} | ||
export declare const cryptoSnapshotSingleTickerFullBook: (apiKey: string, ticker: string) => Promise<ICryptoSingleTickerFullBookFormatted>; | ||
export declare const cryptoSnapshotSingleTickerFullBook: (apiKey: string, ticker: string, apiBase?: string) => Promise<ICryptoSingleTickerFullBookFormatted>; |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cryptoSnapshotSingleTickerFullBook = exports.cryptoSnapshotGainersLosers = exports.cryptoSnapshotSingleTicker = exports.cryptoSnapshotAllTickers = void 0; | ||
const request_1 = require("../transport/request"); | ||
@@ -27,4 +28,4 @@ const ICryptoTickJson_1 = require("./ICryptoTickJson"); | ||
// CF: https://polygon.io/docs/#!/Crypto/get_v2_snapshot_locale_global_markets_crypto_tickers | ||
exports.cryptoSnapshotAllTickers = (apiKey) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v2/snapshot/locale/global/markets/crypto/tickers`, apiKey); | ||
const cryptoSnapshotAllTickers = (apiKey, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v2/snapshot/locale/global/markets/crypto/tickers`, apiKey, undefined, apiBase); | ||
return { | ||
@@ -35,5 +36,6 @@ status: raw.status, | ||
}); | ||
exports.cryptoSnapshotAllTickers = cryptoSnapshotAllTickers; | ||
// CF: https://polygon.io/docs/#!/Crypto/get_v2_snapshot_locale_global_markets_crypto_tickers | ||
exports.cryptoSnapshotSingleTicker = (apiKey, ticker) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v2/snapshot/locale/global/markets/crypto/tickers/${ticker}`, apiKey); | ||
const cryptoSnapshotSingleTicker = (apiKey, ticker, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v2/snapshot/locale/global/markets/crypto/tickers/${ticker}`, apiKey, undefined, apiBase); | ||
return { | ||
@@ -44,5 +46,6 @@ status: raw.status, | ||
}); | ||
exports.cryptoSnapshotSingleTicker = cryptoSnapshotSingleTicker; | ||
// CF: https://polygon.io/docs/#!/Crypto/get_v2_snapshot_locale_global_markets_crypto_direction | ||
exports.cryptoSnapshotGainersLosers = (apiKey, direction = "gainers") => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v2/snapshot/locale/global/markets/crypto/${direction}`, apiKey); | ||
const cryptoSnapshotGainersLosers = (apiKey, direction = "gainers", apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v2/snapshot/locale/global/markets/crypto/${direction}`, apiKey, undefined, apiBase); | ||
return { | ||
@@ -53,2 +56,3 @@ status: raw.status, | ||
}); | ||
exports.cryptoSnapshotGainersLosers = cryptoSnapshotGainersLosers; | ||
const formatICryptoSnapshotBookItemRaw = (raw) => (Object.assign(Object.assign({}, raw), { price: raw.p, exchange: raw.x })); | ||
@@ -62,5 +66,6 @@ const formatICryptoSnapshotTickerBookRaw = (raw) => (Object.assign(Object.assign({}, raw), { bids: raw.bids && raw.bids.length | ||
// CF: https://polygon.io/docs/#!/Crypto/get_v2_snapshot_locale_global_markets_crypto_tickers_ticker_book | ||
exports.cryptoSnapshotSingleTickerFullBook = (apiKey, ticker) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v2/snapshot/locale/global/markets/crypto/tickers/${ticker}/book`, apiKey); | ||
const cryptoSnapshotSingleTickerFullBook = (apiKey, ticker, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v2/snapshot/locale/global/markets/crypto/tickers/${ticker}/book`, apiKey, undefined, apiBase); | ||
return formatICryptoSingleTickerFullBookRaw(raw); | ||
}); | ||
exports.cryptoSnapshotSingleTickerFullBook = cryptoSnapshotSingleTickerFullBook; |
import { IAggregateQuery, IAggResponseFormatted } from "../stocks/aggregates"; | ||
export declare const forexPreviousClose: (apiKey: string, ticker: string, query?: IAggregateQuery) => Promise<IAggResponseFormatted>; | ||
export declare const forexAggregates: (apiKey: string, ticker: string, multiplier: number, timespan: string, from: string, to: string, query?: IAggregateQuery) => Promise<IAggResponseFormatted>; | ||
export declare const forexGroupedDaily: (apiKey: string, locale: string, market: string, date: string, query?: IAggregateQuery) => Promise<IAggResponseFormatted>; | ||
export declare const forexPreviousClose: (apiKey: string, ticker: string, query?: IAggregateQuery, apiBase?: string) => Promise<IAggResponseFormatted>; | ||
export declare const forexAggregates: (apiKey: string, ticker: string, multiplier: number, timespan: string, from: string, to: string, query?: IAggregateQuery, apiBase?: string) => Promise<IAggResponseFormatted>; | ||
export declare const forexGroupedDaily: (apiKey: string, locale: string, market: string, date: string, query?: IAggregateQuery, apiBase?: string) => Promise<IAggResponseFormatted>; |
@@ -12,15 +12,19 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.forexGroupedDaily = exports.forexAggregates = exports.forexPreviousClose = void 0; | ||
const request_1 = require("../transport/request"); | ||
const aggregates_1 = require("../stocks/aggregates"); | ||
// CF: https://polygon.io/docs/#!/Forex--Currencies/get_v2_aggs_ticker_ticker_prev | ||
exports.forexPreviousClose = (apiKey, ticker, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query)); | ||
const forexPreviousClose = (apiKey, ticker, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query, apiBase)); | ||
}); | ||
exports.forexPreviousClose = forexPreviousClose; | ||
// CF: https://polygon.io/docs/#!/Forex--Currencies/get_v2_aggs_ticker_ticker_range_multiplier_timespan_from_to | ||
exports.forexAggregates = (apiKey, ticker, multiplier, timespan, from, to, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/range/${multiplier}/${timespan}/${from}/${to}`, apiKey, query)); | ||
const forexAggregates = (apiKey, ticker, multiplier, timespan, from, to, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/range/${multiplier}/${timespan}/${from}/${to}`, apiKey, query, apiBase)); | ||
}); | ||
exports.forexAggregates = forexAggregates; | ||
// CF: https://polygon.io/docs/#!/Forex--Currencies/get_v2_aggs_grouped_locale_locale_market_market_date | ||
exports.forexGroupedDaily = (apiKey, locale, market = "FX", date, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/grouped/locale/${locale}/market/${market}/${date}`, apiKey, query)); | ||
const forexGroupedDaily = (apiKey, locale, market = "FX", date, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return aggregates_1.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/grouped/locale/${locale}/market/${market}/${date}`, apiKey, query, apiBase)); | ||
}); | ||
exports.forexGroupedDaily = forexGroupedDaily; |
@@ -44,2 +44,2 @@ import { IPolygonQuery } from "../transport/request"; | ||
} | ||
export declare const historicForexTicks: (apiKey: string, from: string, to: string, date: string, query: IHistoricForexTicksQuery) => Promise<IHistoricForexTicksFormatted>; | ||
export declare const historicForexTicks: (apiKey: string, from: string, to: string, date: string, query: IHistoricForexTicksQuery, apiBase?: string) => Promise<IHistoricForexTicksFormatted>; |
@@ -13,7 +13,10 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.historicForexTicks = exports.formatIV1ForexRaw = void 0; | ||
const request_1 = require("../transport/request"); | ||
exports.formatIV1ForexRaw = (raw) => (Object.assign(Object.assign({}, raw), { ask: raw.a, bid: raw.b, timestamp: raw.t })); | ||
const formatIV1ForexRaw = (raw) => (Object.assign(Object.assign({}, raw), { ask: raw.a, bid: raw.b, timestamp: raw.t })); | ||
exports.formatIV1ForexRaw = formatIV1ForexRaw; | ||
const formatIHistoricForexTicksRaw = (raw) => (Object.assign(Object.assign({}, raw), { ticks: raw.ticks.map(exports.formatIV1ForexRaw) })); | ||
exports.historicForexTicks = (apiKey, from, to, date, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatIHistoricForexTicksRaw(yield request_1.get(`/v1/historic/forex/${from}/${to}/${date}`, apiKey, query)); | ||
const historicForexTicks = (apiKey, from, to, date, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatIHistoricForexTicksRaw(yield request_1.get(`/v1/historic/forex/${from}/${to}/${date}`, apiKey, query, apiBase)); | ||
}); | ||
exports.historicForexTicks = historicForexTicks; |
@@ -21,3 +21,3 @@ import { ILastQuoteForCurrencyPair } from "./lastQuoteForCurrencyPair"; | ||
} | ||
export declare const forexClient: (apiKey: string) => IForexClient; | ||
export declare const forexClient: (apiKey: string, apiBase?: string) => IForexClient; | ||
export default forexClient; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.forexClient = void 0; | ||
const request_1 = require("../transport/request"); | ||
@@ -9,14 +10,15 @@ const lastQuoteForCurrencyPair_1 = require("./lastQuoteForCurrencyPair"); | ||
const realTimeCurrencyConversion_1 = require("./realTimeCurrencyConversion"); | ||
exports.forexClient = (apiKey) => ({ | ||
lastQuoteForCurrencyPair: request_1.auth(apiKey, lastQuoteForCurrencyPair_1.lastQuoteForCurrencyPair), | ||
historicTicks: request_1.auth(apiKey, historicForexTicks_1.historicForexTicks), | ||
realTimeCurrencyConversion: request_1.auth(apiKey, realTimeCurrencyConversion_1.realTimeCurrencyConversion), | ||
const forexClient = (apiKey, apiBase) => ({ | ||
lastQuoteForCurrencyPair: request_1.auth(apiKey, lastQuoteForCurrencyPair_1.lastQuoteForCurrencyPair, apiBase), | ||
historicTicks: request_1.auth(apiKey, historicForexTicks_1.historicForexTicks, apiBase), | ||
realTimeCurrencyConversion: request_1.auth(apiKey, realTimeCurrencyConversion_1.realTimeCurrencyConversion, apiBase), | ||
// aggregates | ||
previousClose: request_1.auth(apiKey, aggregates_1.forexPreviousClose), | ||
aggregates: request_1.auth(apiKey, aggregates_1.forexAggregates), | ||
groupedDaily: request_1.auth(apiKey, aggregates_1.forexGroupedDaily), | ||
previousClose: request_1.auth(apiKey, aggregates_1.forexPreviousClose, apiBase), | ||
aggregates: request_1.auth(apiKey, aggregates_1.forexAggregates, apiBase), | ||
groupedDaily: request_1.auth(apiKey, aggregates_1.forexGroupedDaily, apiBase), | ||
// snapshots | ||
snapshotAllTickers: request_1.auth(apiKey, snapshots_1.forexSnapshotAllTickers), | ||
snapshotGainersLosers: request_1.auth(apiKey, snapshots_1.forexSnapshotGainersLosers) | ||
snapshotAllTickers: request_1.auth(apiKey, snapshots_1.forexSnapshotAllTickers, apiBase), | ||
snapshotGainersLosers: request_1.auth(apiKey, snapshots_1.forexSnapshotGainersLosers, apiBase) | ||
}); | ||
exports.forexClient = forexClient; | ||
exports.default = exports.forexClient; |
@@ -12,2 +12,2 @@ export interface ILastQuoteForex { | ||
} | ||
export declare const lastQuoteForCurrencyPair: (apiKey: string, from: string, to: string) => Promise<ILastQuoteForCurrencyPair>; | ||
export declare const lastQuoteForCurrencyPair: (apiKey: string, from: string, to: string, apiBase?: string) => Promise<ILastQuoteForCurrencyPair>; |
"use strict"; | ||
// CF: https://polygon.io/docs/#!/Forex--Currencies/get_v1_last_quote_currencies_from_to | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lastQuoteForCurrencyPair = void 0; | ||
const request_1 = require("../transport/request"); | ||
exports.lastQuoteForCurrencyPair = (apiKey, from, to) => request_1.get(`/v1/last_quote/currencies/${from}/${to}`, apiKey); | ||
const lastQuoteForCurrencyPair = (apiKey, from, to, apiBase) => request_1.get(`/v1/last_quote/currencies/${from}/${to}`, apiKey, undefined, apiBase); | ||
exports.lastQuoteForCurrencyPair = lastQuoteForCurrencyPair; |
@@ -20,2 +20,2 @@ import { IPolygonQuery } from "../transport/request"; | ||
} | ||
export declare const realTimeCurrencyConversion: (apiKey: string, from: string, to: string, query: IRealTimeConversionQuery) => Promise<IRealTimeConversion>; | ||
export declare const realTimeCurrencyConversion: (apiKey: string, from: string, to: string, query: IRealTimeConversionQuery, apiBase?: string) => Promise<IRealTimeConversion>; |
"use strict"; | ||
// CF: https://polygon.io/docs/#!/Forex--Currencies/get_v1_conversion_from_to | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.realTimeCurrencyConversion = void 0; | ||
const request_1 = require("../transport/request"); | ||
exports.realTimeCurrencyConversion = (apiKey, from, to, query) => request_1.get(`/v1/conversion/${from}/${to}`, apiKey, query); | ||
const realTimeCurrencyConversion = (apiKey, from, to, query, apiBase) => request_1.get(`/v1/conversion/${from}/${to}`, apiKey, query, apiBase); | ||
exports.realTimeCurrencyConversion = realTimeCurrencyConversion; |
@@ -49,3 +49,3 @@ import { IV1ForexRaw } from "./historicForexTicks"; | ||
} | ||
export declare const forexSnapshotAllTickers: (apiKey: string) => Promise<IForexSnapshotAllTickersResponseFormatted>; | ||
export declare const forexSnapshotGainersLosers: (apiKey: string, direction?: string) => Promise<IForexSnapshotAllTickersResponseFormatted>; | ||
export declare const forexSnapshotAllTickers: (apiKey: string, apiBase?: string) => Promise<IForexSnapshotAllTickersResponseFormatted>; | ||
export declare const forexSnapshotGainersLosers: (apiKey: string, direction?: string, apiBase?: string) => Promise<IForexSnapshotAllTickersResponseFormatted>; |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.forexSnapshotGainersLosers = exports.forexSnapshotAllTickers = void 0; | ||
const historicForexTicks_1 = require("./historicForexTicks"); | ||
@@ -31,8 +32,10 @@ const request_1 = require("../transport/request"); | ||
// CF: https://polygon.io/docs/#!/Forex--Currencies/get_v2_snapshot_locale_global_markets_forex_tickers | ||
exports.forexSnapshotAllTickers = (apiKey) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatIForexSnapshotAllTickersResponseRaw(yield request_1.get(`/v2/snapshot/locale/global/markets/forex/tickers`, apiKey)); | ||
const forexSnapshotAllTickers = (apiKey, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatIForexSnapshotAllTickersResponseRaw(yield request_1.get(`/v2/snapshot/locale/global/markets/forex/tickers`, apiKey, undefined, apiBase)); | ||
}); | ||
exports.forexSnapshotAllTickers = forexSnapshotAllTickers; | ||
// CF: https://polygon.io/docs/#!/Forex--Currencies/get_v2_snapshot_locale_global_markets_forex_direction | ||
exports.forexSnapshotGainersLosers = (apiKey, direction = "gainers") => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatIForexSnapshotAllTickersResponseRaw(yield request_1.get(`/v2/snapshot/locale/global/markets/forex/${direction}`, apiKey)); | ||
const forexSnapshotGainersLosers = (apiKey, direction = "gainers", apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatIForexSnapshotAllTickersResponseRaw(yield request_1.get(`/v2/snapshot/locale/global/markets/forex/${direction}`, apiKey, undefined, apiBase)); | ||
}); | ||
exports.forexSnapshotGainersLosers = forexSnapshotGainersLosers; |
@@ -15,3 +15,3 @@ import { ICryptoClient } from "./crypto"; | ||
} | ||
export declare const restClient: (apiKey: any) => IRestClient; | ||
export declare const restClient: (apiKey: any, apiBase?: string) => IRestClient; | ||
export default restClient; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.restClient = void 0; | ||
const crypto_1 = require("./crypto"); | ||
@@ -10,12 +18,13 @@ const forex_1 = require("./forex"); | ||
const stocks_1 = require("./stocks"); | ||
__export(require("./crypto")); | ||
__export(require("./forex")); | ||
__export(require("./reference")); | ||
__export(require("./stocks")); | ||
exports.restClient = (apiKey) => ({ | ||
crypto: crypto_1.cryptoClient(apiKey), | ||
forex: forex_1.forexClient(apiKey), | ||
stocks: stocks_1.stocksClient(apiKey), | ||
reference: reference_1.referenceClient(apiKey) | ||
__exportStar(require("./crypto"), exports); | ||
__exportStar(require("./forex"), exports); | ||
__exportStar(require("./reference"), exports); | ||
__exportStar(require("./stocks"), exports); | ||
const restClient = (apiKey, apiBase) => ({ | ||
crypto: crypto_1.cryptoClient(apiKey, apiBase), | ||
forex: forex_1.forexClient(apiKey, apiBase), | ||
stocks: stocks_1.stocksClient(apiKey, apiBase), | ||
reference: reference_1.referenceClient(apiKey, apiBase) | ||
}); | ||
exports.restClient = restClient; | ||
exports.default = exports.restClient; |
@@ -36,3 +36,3 @@ import { ILocalesResponse } from "./locales"; | ||
} | ||
export declare const referenceClient: (apiKey: string) => IReferenceClient; | ||
export declare const referenceClient: (apiKey: string, apiBase?: string) => IReferenceClient; | ||
export default referenceClient; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.referenceClient = void 0; | ||
const request_1 = require("../transport/request"); | ||
@@ -15,15 +16,16 @@ const locales_1 = require("./locales"); | ||
const tickerTypes_1 = require("./tickerTypes"); | ||
exports.referenceClient = (apiKey) => ({ | ||
locales: request_1.auth(apiKey, locales_1.locales), | ||
markets: request_1.auth(apiKey, markets_1.markets), | ||
marketHolydays: request_1.auth(apiKey, marketHolidays_1.marketHolydays), | ||
marketStatus: request_1.auth(apiKey, marketStatus_1.marketStatus), | ||
stockDividends: request_1.auth(apiKey, stockDividends_1.stockDividends), | ||
stockFinancials: request_1.auth(apiKey, stockFinancials_1.stockFinancials), | ||
stockSplits: request_1.auth(apiKey, stockSplits_1.stockSplits), | ||
tickerDetails: request_1.auth(apiKey, tickerDetails_1.tickerDetails), | ||
tickerNews: request_1.auth(apiKey, tickerNews_1.tickerNews), | ||
tickers: request_1.auth(apiKey, tickers_1.tickers), | ||
tickerTypes: request_1.auth(apiKey, tickerTypes_1.tickerTypes) | ||
const referenceClient = (apiKey, apiBase) => ({ | ||
locales: request_1.auth(apiKey, locales_1.locales, apiBase), | ||
markets: request_1.auth(apiKey, markets_1.markets, apiBase), | ||
marketHolydays: request_1.auth(apiKey, marketHolidays_1.marketHolydays, apiBase), | ||
marketStatus: request_1.auth(apiKey, marketStatus_1.marketStatus, apiBase), | ||
stockDividends: request_1.auth(apiKey, stockDividends_1.stockDividends, apiBase), | ||
stockFinancials: request_1.auth(apiKey, stockFinancials_1.stockFinancials, apiBase), | ||
stockSplits: request_1.auth(apiKey, stockSplits_1.stockSplits, apiBase), | ||
tickerDetails: request_1.auth(apiKey, tickerDetails_1.tickerDetails, apiBase), | ||
tickerNews: request_1.auth(apiKey, tickerNews_1.tickerNews, apiBase), | ||
tickers: request_1.auth(apiKey, tickers_1.tickers, apiBase), | ||
tickerTypes: request_1.auth(apiKey, tickerTypes_1.tickerTypes, apiBase) | ||
}); | ||
exports.referenceClient = referenceClient; | ||
exports.default = exports.referenceClient; |
@@ -9,2 +9,2 @@ export interface ILocales { | ||
} | ||
export declare const locales: (apiKeys: string) => Promise<ILocalesResponse>; | ||
export declare const locales: (apiKeys: string, apiBase?: string) => Promise<ILocalesResponse>; |
@@ -12,4 +12,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.locales = void 0; | ||
// CF: https://polygon.io/docs/#!/Reference/get_v2_reference_locales | ||
const request_1 = require("../transport/request"); | ||
exports.locales = (apiKeys) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get("/v2/reference/locales", apiKeys); }); | ||
const locales = (apiKeys, apiBase) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get("/v2/reference/locales", apiKeys, undefined, apiBase); }); | ||
exports.locales = locales; |
@@ -9,2 +9,2 @@ export interface IMarketHolyday { | ||
} | ||
export declare const marketHolydays: (apiKey: string) => Promise<IMarketHolyday[]>; | ||
export declare const marketHolydays: (apiKey: string, apiBase?: string) => Promise<IMarketHolyday[]>; |
@@ -12,4 +12,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.marketHolydays = void 0; | ||
// CF: https://polygon.io/docs/#!/Reference/get_v1_marketstatus_upcoming | ||
const request_1 = require("../transport/request"); | ||
exports.marketHolydays = (apiKey) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get("/v1/marketstatus/upcoming", apiKey); }); | ||
const marketHolydays = (apiKey, apiBase) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get("/v1/marketstatus/upcoming", apiKey, undefined, apiBase); }); | ||
exports.marketHolydays = marketHolydays; |
@@ -9,2 +9,2 @@ export interface IMarket { | ||
} | ||
export declare const markets: (apiKey: string) => Promise<IMarketResponse>; | ||
export declare const markets: (apiKey: string, apiBase?: string) => Promise<IMarketResponse>; |
@@ -12,4 +12,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.markets = void 0; | ||
// CF: https://polygon.io/docs/#!/Reference/get_v2_reference_markets | ||
const request_1 = require("../transport/request"); | ||
exports.markets = (apiKey) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get("/v2/reference/markets", apiKey); }); | ||
const markets = (apiKey, apiBase) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get("/v2/reference/markets", apiKey, undefined, apiBase); }); | ||
exports.markets = markets; |
@@ -16,2 +16,2 @@ export declare type MarketStatus = "open" | "closed"; | ||
} | ||
export declare const marketStatus: (apiKey: string) => Promise<IMarketStatus>; | ||
export declare const marketStatus: (apiKey: string, apiBase?: string) => Promise<IMarketStatus>; |
@@ -13,3 +13,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.marketStatus = void 0; | ||
const request_1 = require("../transport/request"); | ||
exports.marketStatus = (apiKey) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get("/v1/marketstatus/now", apiKey); }); | ||
const marketStatus = (apiKey, apiBase) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get("/v1/marketstatus/now", apiKey, undefined, apiBase); }); | ||
exports.marketStatus = marketStatus; |
@@ -17,2 +17,2 @@ export interface IStockDividend { | ||
} | ||
export declare const stockDividends: (apiKey: string, symbol: string) => Promise<IStockDividendsResults>; | ||
export declare const stockDividends: (apiKey: string, symbol: string, apiBase?: string) => Promise<IStockDividendsResults>; |
@@ -12,4 +12,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stockDividends = void 0; | ||
// CF: https://polygon.io/docs/#!/Reference/get_v2_reference_splits_symbol | ||
const request_1 = require("../transport/request"); | ||
exports.stockDividends = (apiKey, symbol) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get(`/v2/reference/dividends/${symbol}`, apiKey); }); | ||
const stockDividends = (apiKey, symbol, apiBase) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get(`/v2/reference/dividends/${symbol}`, apiKey, undefined, apiBase); }); | ||
exports.stockDividends = stockDividends; |
@@ -124,2 +124,2 @@ import { IPolygonQuery } from "../transport/request"; | ||
} | ||
export declare const stockFinancials: (apiKey: string, symbol: string, query?: IStockFinancialQuery) => Promise<IStockFinancialResults[]>; | ||
export declare const stockFinancials: (apiKey: string, symbol: string, query?: IStockFinancialQuery, apiBase?: string) => Promise<IStockFinancialResults[]>; |
@@ -12,4 +12,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stockFinancials = void 0; | ||
// CF: https://polygon.io/docs/#!/Reference/get_v2_reference_financials_symbol | ||
const request_1 = require("../transport/request"); | ||
exports.stockFinancials = (apiKey, symbol, query) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get(`/v2/reference/financials/${symbol}`, apiKey, query); }); | ||
const stockFinancials = (apiKey, symbol, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get(`/v2/reference/financials/${symbol}`, apiKey, query, apiBase); }); | ||
exports.stockFinancials = stockFinancials; |
@@ -16,2 +16,2 @@ export interface IStockSplit { | ||
} | ||
export declare const stockSplits: (apiKey: string, symbol: string) => Promise<IStockSplitsResults>; | ||
export declare const stockSplits: (apiKey: string, symbol: string, apiBase?: string) => Promise<IStockSplitsResults>; |
@@ -12,4 +12,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stockSplits = void 0; | ||
// CF: https://polygon.io/docs/#!/Reference/get_v2_reference_splits_symbol | ||
const request_1 = require("../transport/request"); | ||
exports.stockSplits = (apiKey, symbol) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get(`/v2/reference/splits/${symbol}`, apiKey); }); | ||
const stockSplits = (apiKey, symbol, apiBase) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get(`/v2/reference/splits/${symbol}`, apiKey, undefined, apiBase); }); | ||
exports.stockSplits = stockSplits; |
@@ -49,2 +49,2 @@ export interface ITickerDetailsRaw { | ||
} | ||
export declare const tickerDetails: (apiKey: string, symbol: string) => Promise<ITickerDetailsFormatted>; | ||
export declare const tickerDetails: (apiKey: string, symbol: string, apiBase?: string) => Promise<ITickerDetailsFormatted>; |
@@ -12,6 +12,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.tickerDetails = void 0; | ||
// CF: https://polygon.io/docs/#!/Reference/get_v1_meta_symbols_symbol_company | ||
const request_1 = require("../transport/request"); | ||
exports.tickerDetails = (apiKey, symbol) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v1/meta/symbols/${symbol}/company`, apiKey); | ||
const tickerDetails = (apiKey, symbol, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
const raw = yield request_1.get(`/v1/meta/symbols/${symbol}/company`, apiKey, undefined, apiBase); | ||
const formatted = Object.assign({}, raw); | ||
@@ -22,1 +23,2 @@ formatted.legalEntityIdentifier = raw.lei; | ||
}); | ||
exports.tickerDetails = tickerDetails; |
@@ -16,2 +16,2 @@ import { IPolygonQuery } from "../transport/request"; | ||
} | ||
export declare const tickerNews: (apiKey: string, symbol: string, query?: ITickerNewsQuery) => Promise<ITickerNews[]>; | ||
export declare const tickerNews: (apiKey: string, symbol: string, query?: ITickerNewsQuery, apiBase?: string) => Promise<ITickerNews[]>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.tickerNews = void 0; | ||
// CF: https://polygon.io/docs/#!/Reference/get_v1_meta_symbols_symbol_news | ||
const request_1 = require("../transport/request"); | ||
exports.tickerNews = (apiKey, symbol, query) => request_1.get(`/v1/meta/symbols/${symbol}/news`, apiKey, query); | ||
const tickerNews = (apiKey, symbol, query, apiBase) => request_1.get(`/v1/meta/symbols/${symbol}/news`, apiKey, query, apiBase); | ||
exports.tickerNews = tickerNews; |
@@ -27,2 +27,2 @@ import { IPolygonQuery } from "../transport/request"; | ||
} | ||
export declare const tickers: (apiKey: string, query?: ITickersQuery) => Promise<ITickers[]>; | ||
export declare const tickers: (apiKey: string, query?: ITickersQuery, apiBase?: string) => Promise<ITickers[]>; |
@@ -12,7 +12,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.tickers = void 0; | ||
// CF: https://polygon.io/docs/#!/Reference/get_v2_reference_tickers | ||
const request_1 = require("../transport/request"); | ||
exports.tickers = (apiKey, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
const tickers = (apiKey, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
const path = "/v2/reference/tickers"; | ||
return request_1.get(path, apiKey, query); | ||
return request_1.get(path, apiKey, query, apiBase); | ||
}); | ||
exports.tickers = tickers; |
@@ -5,2 +5,2 @@ export interface ITickerTypes { | ||
} | ||
export declare const tickerTypes: (apiKeys: string) => Promise<ITickerTypes>; | ||
export declare const tickerTypes: (apiKeys: string, apiBase?: string) => Promise<ITickerTypes>; |
@@ -12,4 +12,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.tickerTypes = void 0; | ||
// CF: https://polygon.io/docs/#!/Reference/get_v2_reference_types | ||
const request_1 = require("../transport/request"); | ||
exports.tickerTypes = (apiKeys) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get("/v2/reference/types", apiKeys); }); | ||
const tickerTypes = (apiKeys, apiBase) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get("/v2/reference/types", apiKeys, undefined, apiBase); }); | ||
exports.tickerTypes = tickerTypes; |
@@ -50,4 +50,4 @@ import { IPolygonQuery } from "../transport/request"; | ||
} | ||
export declare const stocksPreviousClose: (apiKey: string, ticker: string, query?: IAggregateQuery) => Promise<IAggResponseFormatted>; | ||
export declare const stocksAggregates: (apikey: string, ticker: string, multiplier: number, timespan: string, from: string, to: string, query?: IAggregateQuery) => Promise<IAggResponseFormatted>; | ||
export declare const stocksGroupedDaily: (apiKey: string, locale: string, market: string, date: string, query?: IAggregateQuery) => Promise<IAggResponseFormatted>; | ||
export declare const stocksPreviousClose: (apiKey: string, ticker: string, query?: IAggregateQuery, apiBase?: string) => Promise<IAggResponseFormatted>; | ||
export declare const stocksAggregates: (apikey: string, ticker: string, multiplier: number, timespan: string, from: string, to: string, query?: IAggregateQuery, apiBase?: string) => Promise<IAggResponseFormatted>; | ||
export declare const stocksGroupedDaily: (apiKey: string, locale: string, market: string, date: string, query?: IAggregateQuery, apiBase?: string) => Promise<IAggResponseFormatted>; |
@@ -12,16 +12,21 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stocksGroupedDaily = exports.stocksAggregates = exports.stocksPreviousClose = exports.formatIAggResponseRaw = void 0; | ||
const request_1 = require("../transport/request"); | ||
const formatIAggv2Raw = (raw) => (Object.assign(Object.assign({}, raw), { tickerSymbol: raw.T, volume: raw.v, open: raw.o, close: raw.c, high: raw.h, low: raw.l, timestamp: raw.t, numberOfItems: raw.n })); | ||
exports.formatIAggResponseRaw = (raw) => (Object.assign(Object.assign({}, raw), { results: raw.results.map(formatIAggv2Raw) })); | ||
const formatIAggResponseRaw = (raw) => (Object.assign(Object.assign({}, raw), { results: raw.results.map(formatIAggv2Raw) })); | ||
exports.formatIAggResponseRaw = formatIAggResponseRaw; | ||
// CF : https://polygon.io/docs/#!/Stocks--Equities/get_v2_aggs_ticker_ticker_prev | ||
exports.stocksPreviousClose = (apiKey, ticker, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query)); | ||
const stocksPreviousClose = (apiKey, ticker, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query, apiBase)); | ||
}); | ||
exports.stocksPreviousClose = stocksPreviousClose; | ||
// CF: https://polygon.io/docs/#!/Stocks--Equities/get_v2_aggs_ticker_ticker_range_multiplier_timespan_from_to | ||
exports.stocksAggregates = (apikey, ticker, multiplier, timespan, from, to, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/range/${multiplier}/${timespan}/${from}/${to}`, apikey, query)); | ||
const stocksAggregates = (apikey, ticker, multiplier, timespan, from, to, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/ticker/${ticker}/range/${multiplier}/${timespan}/${from}/${to}`, apikey, query, apiBase)); | ||
}); | ||
exports.stocksAggregates = stocksAggregates; | ||
// CF: https://polygon.io/docs/#!/Stocks--Equities/get_v2_aggs_grouped_locale_locale_market_market_date | ||
exports.stocksGroupedDaily = (apiKey, locale, market, date, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/grouped/locale/${locale}/market/${market}/${date}`, apiKey, query)); | ||
const stocksGroupedDaily = (apiKey, locale, market, date, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIAggResponseRaw(yield request_1.get(`/v2/aggs/grouped/locale/${locale}/market/${market}/${date}`, apiKey, query, apiBase)); | ||
}); | ||
exports.stocksGroupedDaily = stocksGroupedDaily; |
export interface IConditionMappings { | ||
[key: string]: string; | ||
} | ||
export declare const conditionMappings: (apiKeys: string, ticktype?: string) => Promise<IConditionMappings>; | ||
export declare const conditionMappings: (apiKeys: string, ticktype?: string, apiBase?: string) => Promise<IConditionMappings>; |
@@ -12,4 +12,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.conditionMappings = void 0; | ||
// CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_meta_conditions_ticktype | ||
const request_1 = require("../transport/request"); | ||
exports.conditionMappings = (apiKeys, ticktype = "trades") => __awaiter(void 0, void 0, void 0, function* () { return request_1.get(`/v1/meta/conditions/${ticktype}`, apiKeys); }); | ||
const conditionMappings = (apiKeys, ticktype = "trades", apiBase) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get(`/v1/meta/conditions/${ticktype}`, apiKeys, undefined, apiBase); }); | ||
exports.conditionMappings = conditionMappings; |
@@ -17,2 +17,2 @@ export interface IHistTrade { | ||
} | ||
export declare const dailyOpenClose: (apiKey: string, symbol: string, date: string) => Promise<IDailyOpenClose>; | ||
export declare const dailyOpenClose: (apiKey: string, symbol: string, date: string, apiBase?: string) => Promise<IDailyOpenClose>; |
@@ -12,4 +12,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.dailyOpenClose = void 0; | ||
// CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_open_close_symbol_date | ||
const request_1 = require("../transport/request"); | ||
exports.dailyOpenClose = (apiKey, symbol, date) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get(`/v1/open-close/${symbol}/${date}`, apiKey); }); | ||
const dailyOpenClose = (apiKey, symbol, date, apiBase) => __awaiter(void 0, void 0, void 0, function* () { return request_1.get(`/v1/open-close/${symbol}/${date}`, apiKey, undefined, apiBase); }); | ||
exports.dailyOpenClose = dailyOpenClose; |
@@ -18,2 +18,2 @@ export interface IExchangeRaw { | ||
} | ||
export declare const exchanges: (apiKey: string) => Promise<IExchangeFormatted[]>; | ||
export declare const exchanges: (apiKey: string, apiBase?: string) => Promise<IExchangeFormatted[]>; |
@@ -12,5 +12,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.exchanges = void 0; | ||
// CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_meta_exchanges | ||
const request_1 = require("../transport/request"); | ||
const formatIExchangeRaw = (raw) => (Object.assign(Object.assign({}, raw), { marketIdentifierCode: raw.mic })); | ||
exports.exchanges = (apiKey) => __awaiter(void 0, void 0, void 0, function* () { return (yield request_1.get(`/v1/meta/exchanges`, apiKey)).map(formatIExchangeRaw); }); | ||
const exchanges = (apiKey, apiBase) => __awaiter(void 0, void 0, void 0, function* () { return (yield request_1.get(`/v1/meta/exchanges`, apiKey, undefined, apiBase)).map(formatIExchangeRaw); }); | ||
exports.exchanges = exchanges; |
@@ -40,3 +40,3 @@ import { IAggregateQuery, IAggResponseFormatted } from "./aggregates"; | ||
} | ||
export declare const stocksClient: (apiKey: string) => IStocksClient; | ||
export declare const stocksClient: (apiKey: string, apiBase?: string) => IStocksClient; | ||
export default stocksClient; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stocksClient = void 0; | ||
const request_1 = require("../transport/request"); | ||
@@ -15,21 +16,22 @@ const aggregates_1 = require("./aggregates"); | ||
const v2HistoricTrades_1 = require("./v2HistoricTrades"); | ||
exports.stocksClient = (apiKey) => ({ | ||
conditionMappings: request_1.auth(apiKey, conditionMappings_1.conditionMappings), | ||
dailyOpenClose: request_1.auth(apiKey, dailyOpenClose_1.dailyOpenClose), | ||
exchanges: request_1.auth(apiKey, exchanges_1.exchanges), | ||
lastQuoteForSymbol: request_1.auth(apiKey, lastQuoteForSymbol_1.lastQuoteForSymbol), | ||
lastTradeForSymbol: request_1.auth(apiKey, lastTradeForSymbol_1.lastTradeForSymbol), | ||
v1HistoricQuotes: request_1.auth(apiKey, v1HistoricQuotes_1.v1HistoricQuotes), | ||
v1HistoricTrades: request_1.auth(apiKey, v1HistoricTrades_1.v1HistoricTrades), | ||
v2HistoricQuotes: request_1.auth(apiKey, v2HistoricQuotes_1.v2HistoricQuotes), | ||
v2HistoricTrades: request_1.auth(apiKey, v2HistoricTrades_1.v2HistoricTrades), | ||
const stocksClient = (apiKey, apiBase) => ({ | ||
conditionMappings: request_1.auth(apiKey, conditionMappings_1.conditionMappings, apiBase), | ||
dailyOpenClose: request_1.auth(apiKey, dailyOpenClose_1.dailyOpenClose, apiBase), | ||
exchanges: request_1.auth(apiKey, exchanges_1.exchanges, apiBase), | ||
lastQuoteForSymbol: request_1.auth(apiKey, lastQuoteForSymbol_1.lastQuoteForSymbol, apiBase), | ||
lastTradeForSymbol: request_1.auth(apiKey, lastTradeForSymbol_1.lastTradeForSymbol, apiBase), | ||
v1HistoricQuotes: request_1.auth(apiKey, v1HistoricQuotes_1.v1HistoricQuotes, apiBase), | ||
v1HistoricTrades: request_1.auth(apiKey, v1HistoricTrades_1.v1HistoricTrades, apiBase), | ||
v2HistoricQuotes: request_1.auth(apiKey, v2HistoricQuotes_1.v2HistoricQuotes, apiBase), | ||
v2HistoricTrades: request_1.auth(apiKey, v2HistoricTrades_1.v2HistoricTrades, apiBase), | ||
// snapshot | ||
snapshotAllTickers: request_1.auth(apiKey, snapshots_1.snapshotAllTickers), | ||
snapshotSingleTicker: request_1.auth(apiKey, snapshots_1.snapshotSingleTicker), | ||
snapshotGainersLosers: request_1.auth(apiKey, snapshots_1.snapshotGainersLosers), | ||
snapshotAllTickers: request_1.auth(apiKey, snapshots_1.snapshotAllTickers, apiBase), | ||
snapshotSingleTicker: request_1.auth(apiKey, snapshots_1.snapshotSingleTicker, apiBase), | ||
snapshotGainersLosers: request_1.auth(apiKey, snapshots_1.snapshotGainersLosers, apiBase), | ||
// aggregates | ||
previousClose: request_1.auth(apiKey, aggregates_1.stocksPreviousClose), | ||
aggregates: request_1.auth(apiKey, aggregates_1.stocksAggregates), | ||
groupedDaily: request_1.auth(apiKey, aggregates_1.stocksGroupedDaily) | ||
previousClose: request_1.auth(apiKey, aggregates_1.stocksPreviousClose, apiBase), | ||
aggregates: request_1.auth(apiKey, aggregates_1.stocksAggregates, apiBase), | ||
groupedDaily: request_1.auth(apiKey, aggregates_1.stocksGroupedDaily, apiBase) | ||
}); | ||
exports.stocksClient = stocksClient; | ||
exports.default = exports.stocksClient; |
@@ -15,2 +15,2 @@ export interface ILastQuote { | ||
} | ||
export declare const lastQuoteForSymbol: (apiKey: string, symbol: string) => Promise<ILastQuoteResult>; | ||
export declare const lastQuoteForSymbol: (apiKey: string, symbol: string, apiBase?: string) => Promise<ILastQuoteResult>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lastQuoteForSymbol = void 0; | ||
// CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_last_quote_stocks_symbol | ||
const request_1 = require("../transport/request"); | ||
exports.lastQuoteForSymbol = (apiKey, symbol) => request_1.get(`/v1/last_quote/stocks/${symbol}`, apiKey); | ||
const lastQuoteForSymbol = (apiKey, symbol, apiBase) => request_1.get(`/v1/last_quote/stocks/${symbol}`, apiKey, undefined, apiBase); | ||
exports.lastQuoteForSymbol = lastQuoteForSymbol; |
@@ -16,2 +16,2 @@ export interface ILastTrade { | ||
} | ||
export declare const lastTradeForSymbol: (apiKey: string, symbol: string) => Promise<ILastTradeResult>; | ||
export declare const lastTradeForSymbol: (apiKey: string, symbol: string, apiBase?: string) => Promise<ILastTradeResult>; |
"use strict"; | ||
// CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_last_stocks_symbol | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lastTradeForSymbol = void 0; | ||
const request_1 = require("../transport/request"); | ||
exports.lastTradeForSymbol = (apiKey, symbol) => request_1.get(`/v1/last/stocks/${symbol}`, apiKey); | ||
const lastTradeForSymbol = (apiKey, symbol, apiBase) => request_1.get(`/v1/last/stocks/${symbol}`, apiKey, undefined, apiBase); | ||
exports.lastTradeForSymbol = lastTradeForSymbol; |
@@ -73,3 +73,3 @@ import { ITradeV1Raw, ITradeV1Formatted } from "./v1HistoricTrades"; | ||
} | ||
export declare const snapshotAllTickers: (apiKey: string) => Promise<ISnapshotAllTickersResultFormatted>; | ||
export declare const snapshotAllTickers: (apiKey: string, apiBase?: string) => Promise<ISnapshotAllTickersResultFormatted>; | ||
export interface ISnapshotSingleTickerResultRaw { | ||
@@ -83,3 +83,3 @@ status: string; | ||
} | ||
export declare const snapshotSingleTicker: (apiKey: string, ticker: string) => Promise<ISnapshotSingleTickerResultFormatted>; | ||
export declare const snapshotSingleTicker: (apiKey: string, ticker: string, apiBase?: string) => Promise<ISnapshotSingleTickerResultFormatted>; | ||
export interface ISnapshotGainersLosersResultRaw { | ||
@@ -93,2 +93,2 @@ status: string; | ||
} | ||
export declare const snapshotGainersLosers: (apiKey: string, direction?: string) => Promise<ISnapshotGainersLosersResultFormatted>; | ||
export declare const snapshotGainersLosers: (apiKey: string, direction?: string, apiBase?: string) => Promise<ISnapshotGainersLosersResultFormatted>; |
@@ -12,17 +12,24 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.snapshotGainersLosers = exports.snapshotSingleTicker = exports.snapshotAllTickers = exports.formatIStocksSnapshotTickerRaw = exports.formatIStocksSnapshotQuoteRaw = exports.formatIStocksSnapshotAggRaw = void 0; | ||
const request_1 = require("../transport/request"); | ||
const v1HistoricTrades_1 = require("./v1HistoricTrades"); | ||
exports.formatIStocksSnapshotAggRaw = (raw) => (Object.assign(Object.assign({}, raw), { close: raw.c, high: raw.h, low: raw.l, open: raw.o, volume: raw.v })); | ||
exports.formatIStocksSnapshotQuoteRaw = (raw) => (Object.assign(Object.assign({}, raw), { bidPrice: raw.p, bidSize: raw.s, askPrice: raw.P, askSize: raw.S, lastUpdateTimestam: raw.t })); | ||
exports.formatIStocksSnapshotTickerRaw = (raw) => (Object.assign(Object.assign({}, raw), { day: exports.formatIStocksSnapshotAggRaw(raw.day), lastTrade: v1HistoricTrades_1.formatITradeV1Raw(raw.lastTrade), lastQuote: exports.formatIStocksSnapshotQuoteRaw(raw.lastQuote), min: exports.formatIStocksSnapshotAggRaw(raw.min), prevDay: exports.formatIStocksSnapshotAggRaw(raw.prevDay) })); | ||
const formatIStocksSnapshotAggRaw = (raw) => (Object.assign(Object.assign({}, raw), { close: raw.c, high: raw.h, low: raw.l, open: raw.o, volume: raw.v })); | ||
exports.formatIStocksSnapshotAggRaw = formatIStocksSnapshotAggRaw; | ||
const formatIStocksSnapshotQuoteRaw = (raw) => (Object.assign(Object.assign({}, raw), { bidPrice: raw.p, bidSize: raw.s, askPrice: raw.P, askSize: raw.S, lastUpdateTimestam: raw.t })); | ||
exports.formatIStocksSnapshotQuoteRaw = formatIStocksSnapshotQuoteRaw; | ||
const formatIStocksSnapshotTickerRaw = (raw) => (Object.assign(Object.assign({}, raw), { day: exports.formatIStocksSnapshotAggRaw(raw.day), lastTrade: v1HistoricTrades_1.formatITradeV1Raw(raw.lastTrade), lastQuote: exports.formatIStocksSnapshotQuoteRaw(raw.lastQuote), min: exports.formatIStocksSnapshotAggRaw(raw.min), prevDay: exports.formatIStocksSnapshotAggRaw(raw.prevDay) })); | ||
exports.formatIStocksSnapshotTickerRaw = formatIStocksSnapshotTickerRaw; | ||
const formatISnapshotAllTickersResultRaw = (raw) => (Object.assign(Object.assign({}, raw), { tickers: raw.tickers.map(exports.formatIStocksSnapshotTickerRaw) })); | ||
exports.snapshotAllTickers = (apiKey) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatISnapshotAllTickersResultRaw(yield request_1.get(`/v2/snapshot/locale/us/markets/stocks/tickers`, apiKey)); | ||
const snapshotAllTickers = (apiKey, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatISnapshotAllTickersResultRaw(yield request_1.get(`/v2/snapshot/locale/us/markets/stocks/tickers`, apiKey, undefined, apiBase)); | ||
}); | ||
exports.snapshotAllTickers = snapshotAllTickers; | ||
const formatISnapshotSingleTickerResultRaw = (raw) => (Object.assign(Object.assign({}, raw), { ticker: exports.formatIStocksSnapshotTickerRaw(raw.ticker) })); | ||
exports.snapshotSingleTicker = (apiKey, ticker) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatISnapshotSingleTickerResultRaw(yield request_1.get(`/v2/snapshot/locale/us/markets/stocks/tickers/${ticker}`, apiKey)); | ||
const snapshotSingleTicker = (apiKey, ticker, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatISnapshotSingleTickerResultRaw(yield request_1.get(`/v2/snapshot/locale/us/markets/stocks/tickers/${ticker}`, apiKey, undefined, apiBase)); | ||
}); | ||
exports.snapshotGainersLosers = (apiKey, direction = "gainers") => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatISnapshotAllTickersResultRaw(yield request_1.get(`/v2/snapshot/locale/us/markets/stocks/${direction}`, apiKey)); | ||
exports.snapshotSingleTicker = snapshotSingleTicker; | ||
const snapshotGainersLosers = (apiKey, direction = "gainers", apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatISnapshotAllTickersResultRaw(yield request_1.get(`/v2/snapshot/locale/us/markets/stocks/${direction}`, apiKey, undefined, apiBase)); | ||
}); | ||
exports.snapshotGainersLosers = snapshotGainersLosers; |
@@ -70,2 +70,2 @@ import { IPolygonQuery } from "../transport/request"; | ||
export declare const formatIV1HistoricQuotesResultRaw: (raw: IV1HistoricQuotesResultRaw) => IV1HistoricQuotesResultFormatted; | ||
export declare const v1HistoricQuotes: (apiKey: string, symbol: string, date: string, query?: IV1HistoricQuotesQuery) => Promise<IV1HistoricQuotesResultFormatted>; | ||
export declare const v1HistoricQuotes: (apiKey: string, symbol: string, date: string, query?: IV1HistoricQuotesQuery, apiBase?: string) => Promise<IV1HistoricQuotesResultFormatted>; |
@@ -12,8 +12,12 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.v1HistoricQuotes = exports.formatIV1HistoricQuotesResultRaw = exports.formatIQuoteV1Raw = void 0; | ||
// CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_historic_quotes_symbol_date | ||
const request_1 = require("../transport/request"); | ||
exports.formatIQuoteV1Raw = (raw) => (Object.assign(Object.assign({}, raw), { condition: raw.c, bidExchange: raw.bE, askExchange: raw.aE, askPrice: raw.aP, buyPrice: raw.bP, bidSize: raw.bS, askSize: raw.aS, timestamp: raw.t })); | ||
exports.formatIV1HistoricQuotesResultRaw = (raw) => (Object.assign(Object.assign({}, raw), { ticks: raw.ticks.map(exports.formatIQuoteV1Raw) })); | ||
exports.v1HistoricQuotes = (apiKey, symbol, date, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIV1HistoricQuotesResultRaw(yield request_1.get(`/v1/historic/quotes/${symbol}/${date}`, apiKey, query)); | ||
const formatIQuoteV1Raw = (raw) => (Object.assign(Object.assign({}, raw), { condition: raw.c, bidExchange: raw.bE, askExchange: raw.aE, askPrice: raw.aP, buyPrice: raw.bP, bidSize: raw.bS, askSize: raw.aS, timestamp: raw.t })); | ||
exports.formatIQuoteV1Raw = formatIQuoteV1Raw; | ||
const formatIV1HistoricQuotesResultRaw = (raw) => (Object.assign(Object.assign({}, raw), { ticks: raw.ticks.map(exports.formatIQuoteV1Raw) })); | ||
exports.formatIV1HistoricQuotesResultRaw = formatIV1HistoricQuotesResultRaw; | ||
const v1HistoricQuotes = (apiKey, symbol, date, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIV1HistoricQuotesResultRaw(yield request_1.get(`/v1/historic/quotes/${symbol}/${date}`, apiKey, query, apiBase)); | ||
}); | ||
exports.v1HistoricQuotes = v1HistoricQuotes; |
@@ -70,2 +70,2 @@ import { IPolygonQuery } from "../transport/request"; | ||
export declare const formatIV1HistoricTradesResultRaw: (raw: IV1HistoricTradesResultRaw) => IV1HistoricTradesResultFormatted; | ||
export declare const v1HistoricTrades: (apiKey: string, symbol: string, date: string, query?: IV1HistoricTradesQuery) => Promise<IV1HistoricTradesResultFormatted>; | ||
export declare const v1HistoricTrades: (apiKey: string, symbol: string, date: string, query?: IV1HistoricTradesQuery, apiBase?: string) => Promise<IV1HistoricTradesResultFormatted>; |
@@ -12,8 +12,12 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.v1HistoricTrades = exports.formatIV1HistoricTradesResultRaw = exports.formatITradeV1Raw = void 0; | ||
// CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_historic_trades_symbol_date | ||
const request_1 = require("../transport/request"); | ||
exports.formatITradeV1Raw = (raw) => (Object.assign(Object.assign({}, raw), { condition1: raw.c1, condition2: raw.c2, condition3: raw.c3, condition4: raw.c4, exchange: raw.e, price: raw.p, size: raw.s, timestamp: raw.t })); | ||
exports.formatIV1HistoricTradesResultRaw = (raw) => (Object.assign(Object.assign({}, raw), { ticks: raw.ticks.map(exports.formatITradeV1Raw) })); | ||
exports.v1HistoricTrades = (apiKey, symbol, date, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIV1HistoricTradesResultRaw(yield request_1.get(`/v1/historic/trades/${symbol}/${date}`, apiKey, query)); | ||
const formatITradeV1Raw = (raw) => (Object.assign(Object.assign({}, raw), { condition1: raw.c1, condition2: raw.c2, condition3: raw.c3, condition4: raw.c4, exchange: raw.e, price: raw.p, size: raw.s, timestamp: raw.t })); | ||
exports.formatITradeV1Raw = formatITradeV1Raw; | ||
const formatIV1HistoricTradesResultRaw = (raw) => (Object.assign(Object.assign({}, raw), { ticks: raw.ticks.map(exports.formatITradeV1Raw) })); | ||
exports.formatIV1HistoricTradesResultRaw = formatIV1HistoricTradesResultRaw; | ||
const v1HistoricTrades = (apiKey, symbol, date, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIV1HistoricTradesResultRaw(yield request_1.get(`/v1/historic/trades/${symbol}/${date}`, apiKey, query, apiBase)); | ||
}); | ||
exports.v1HistoricTrades = v1HistoricTrades; |
@@ -69,2 +69,2 @@ import { IPolygonQuery } from "../transport/request"; | ||
} | ||
export declare const v2HistoricQuotes: (apiKey: string, symbol: string, date: string, query?: IV2HistoricQuotesQuery) => Promise<IV2HistoricQuotesResultFormatted>; | ||
export declare const v2HistoricQuotes: (apiKey: string, symbol: string, date: string, query?: IV2HistoricQuotesQuery, apiBase?: string) => Promise<IV2HistoricQuotesResultFormatted>; |
@@ -12,8 +12,11 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.v2HistoricQuotes = exports.formatIQuoteV2Raw = void 0; | ||
// CF: https://polygon.io/docs/#!/Stocks--Equities/get_v2_ticks_stocks_nbbo_ticker_date | ||
const request_1 = require("../transport/request"); | ||
exports.formatIQuoteV2Raw = (raw) => (Object.assign(Object.assign({}, raw), { ticker: raw.T, SIPTimestamp: raw.t, participantExchangeTimestamp: raw.y, tradeReportingFacilityTimestamp: raw.f, sequenceNumber: raw.q, conditions: raw.c, indicators: raw.i, bidPrice: raw.p, bidExchangeId: raw.x, bidSize: raw.s, askPrice: raw.p, askExchangeId: raw.X, askSize: raw.S, tapeWhereTradeOccured: raw.z })); | ||
const formatIQuoteV2Raw = (raw) => (Object.assign(Object.assign({}, raw), { ticker: raw.T, SIPTimestamp: raw.t, participantExchangeTimestamp: raw.y, tradeReportingFacilityTimestamp: raw.f, sequenceNumber: raw.q, conditions: raw.c, indicators: raw.i, bidPrice: raw.p, bidExchangeId: raw.x, bidSize: raw.s, askPrice: raw.p, askExchangeId: raw.X, askSize: raw.S, tapeWhereTradeOccured: raw.z })); | ||
exports.formatIQuoteV2Raw = formatIQuoteV2Raw; | ||
const formatIV2HistoricQuotesResultRaw = (raw) => (Object.assign(Object.assign({}, raw), { results: raw.results && raw.results.map(exports.formatIQuoteV2Raw) })); | ||
exports.v2HistoricQuotes = (apiKey, symbol, date, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatIV2HistoricQuotesResultRaw(yield request_1.get(`/v2/ticks/stocks/nbbo/${symbol}/${date}`, apiKey, query)); | ||
const v2HistoricQuotes = (apiKey, symbol, date, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return formatIV2HistoricQuotesResultRaw(yield request_1.get(`/v2/ticks/stocks/nbbo/${symbol}/${date}`, apiKey, query, apiBase)); | ||
}); | ||
exports.v2HistoricQuotes = v2HistoricQuotes; |
@@ -61,2 +61,2 @@ import { IPolygonQuery } from "../transport/request"; | ||
export declare const formatIV2HistoricTradeResultRaw: (raw: IV2HistoricTradesResultRaw) => IV2HistoricTradesResultFormatted; | ||
export declare const v2HistoricTrades: (apiKey: string, symbol: string, date: string, query?: IV2HistoricTradesQuery) => Promise<IV2HistoricTradesResultFormatted>; | ||
export declare const v2HistoricTrades: (apiKey: string, symbol: string, date: string, query?: IV2HistoricTradesQuery, apiBase?: string) => Promise<IV2HistoricTradesResultFormatted>; |
@@ -12,8 +12,12 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.v2HistoricTrades = exports.formatIV2HistoricTradeResultRaw = exports.formatITradeV2Raw = void 0; | ||
// CF: https://polygon.io/docs/#!/Stocks--Equities/get_v2_ticks_stocks_trades_ticker_date | ||
const request_1 = require("../transport/request"); | ||
exports.formatITradeV2Raw = (raw) => (Object.assign(Object.assign({}, raw), { ticker: raw.T, SIPTimestamp: raw.t, participantExchangeTimestamp: raw.y, tradeReportingFacilityTimestamp: raw.y, sequenceNumber: raw.q, tradeId: raw.i, exchange: raw.x, size: raw.s, conditions: raw.c, price: raw.p, tapeWhereTheTradeOccured: raw.z })); | ||
exports.formatIV2HistoricTradeResultRaw = (raw) => (Object.assign(Object.assign({}, raw), { ticks: raw.ticks.map(exports.formatITradeV2Raw) })); | ||
exports.v2HistoricTrades = (apiKey, symbol, date, query) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIV2HistoricTradeResultRaw(yield request_1.get(`/v2/ticks/stocks/trades/${symbol}/${date}`, apiKey, query)); | ||
const formatITradeV2Raw = (raw) => (Object.assign(Object.assign({}, raw), { ticker: raw.T, SIPTimestamp: raw.t, participantExchangeTimestamp: raw.y, tradeReportingFacilityTimestamp: raw.y, sequenceNumber: raw.q, tradeId: raw.i, exchange: raw.x, size: raw.s, conditions: raw.c, price: raw.p, tapeWhereTheTradeOccured: raw.z })); | ||
exports.formatITradeV2Raw = formatITradeV2Raw; | ||
const formatIV2HistoricTradeResultRaw = (raw) => (Object.assign(Object.assign({}, raw), { ticks: raw.ticks.map(exports.formatITradeV2Raw) })); | ||
exports.formatIV2HistoricTradeResultRaw = formatIV2HistoricTradeResultRaw; | ||
const v2HistoricTrades = (apiKey, symbol, date, query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
return exports.formatIV2HistoricTradeResultRaw(yield request_1.get(`/v2/ticks/stocks/trades/${symbol}/${date}`, apiKey, query, apiBase)); | ||
}); | ||
exports.v2HistoricTrades = v2HistoricTrades; |
export interface IPolygonQuery { | ||
[key: string]: string | number | boolean; | ||
[key: string]: string | number | boolean | undefined; | ||
} | ||
@@ -7,3 +7,3 @@ export interface IPolygonQueryWithCredentials extends IPolygonQuery { | ||
} | ||
export declare const auth: (apiKey: any, func: any) => (...args: any[]) => any; | ||
export declare const get: (path: string, apiKey?: string, query?: IPolygonQuery) => Promise<any>; | ||
export declare const auth: (apiKey: any, func: Function, apiBase: string) => (...args: any[]) => any; | ||
export declare const get: (path: string, apiKey?: string, query?: IPolygonQuery, apiBase?: string) => Promise<any>; |
"use strict"; | ||
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 }); | ||
const https = require("https"); | ||
const querystring = require("querystring"); | ||
exports.auth = (apiKey, func) => (...args) => func(apiKey, ...args); | ||
exports.get = (path, apiKey = "invalid", query) => new Promise((resolve, reject) => { | ||
exports.get = exports.auth = void 0; | ||
const cross_fetch_1 = require("cross-fetch"); | ||
const query_string_1 = require("query-string"); | ||
const auth = (apiKey, func, apiBase) => (...args) => func(apiKey, ...args, apiBase); | ||
exports.auth = auth; | ||
const get = (path, apiKey = "invalid", query, apiBase) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (!apiKey) { | ||
@@ -11,21 +22,11 @@ throw new Error("API KEY not configured..."); | ||
const authenticatedQuery = Object.assign(Object.assign({}, query), { apiKey }); | ||
const options = { | ||
protocol: "https:", | ||
method: "GET", | ||
host: "api.polygon.io", | ||
path: path + "?" + querystring.encode(authenticatedQuery) | ||
}; | ||
const request = https.request(options, (response) => { | ||
let data = ""; | ||
response.on("data", function (chunk) { | ||
data += chunk; | ||
}); | ||
response.on("end", function () { | ||
resolve(JSON.parse(data)); | ||
}); | ||
}); | ||
request.on("error", (error) => { | ||
reject(error); | ||
}); | ||
request.end(); | ||
const queryString = query_string_1.stringify(authenticatedQuery, { encode: true }); | ||
const url = `${apiBase}${path}?${queryString}`; | ||
const response = yield cross_fetch_1.default(url); | ||
if (response.status >= 400) { | ||
const message = yield response.text(); | ||
throw new Error(message); | ||
} | ||
return response.json(); | ||
}); | ||
exports.get = get; |
@@ -1,2 +0,2 @@ | ||
import * as WebSocket from "ws"; | ||
import { w3cwebsocket as Websocket } from "websocket"; | ||
export interface IQuoteCryptoEvent { | ||
@@ -61,2 +61,2 @@ ev: string; | ||
} | ||
export declare const getCryptoWebsocket: (apiKey: string) => WebSocket; | ||
export declare const getCryptoWebsocket: (apiKey: string, apiBase?: string) => Websocket; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getCryptoWebsocket = void 0; | ||
const transport_1 = require("../transport"); | ||
exports.getCryptoWebsocket = (apiKey) => transport_1.getWsClient("wss://socket.polygon.io/crypto", apiKey); | ||
const getCryptoWebsocket = (apiKey, apiBase) => transport_1.getWsClient(`${apiBase}/crypto`, apiKey); | ||
exports.getCryptoWebsocket = getCryptoWebsocket; |
@@ -1,2 +0,2 @@ | ||
import * as WebSocket from "ws"; | ||
import { w3cwebsocket as Websocket } from "websocket"; | ||
export interface IQuoteForexEvent { | ||
@@ -20,2 +20,2 @@ ev: string; | ||
} | ||
export declare const getForexWebsocket: (apiKey: string) => WebSocket; | ||
export declare const getForexWebsocket: (apiKey: string, apiBase?: string) => Websocket; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getForexWebsocket = void 0; | ||
// Forex QUOTE: | ||
const transport_1 = require("../transport"); | ||
exports.getForexWebsocket = (apiKey) => transport_1.getWsClient("wss://socket.polygon.io/forex", apiKey); | ||
const getForexWebsocket = (apiKey, apiBase) => transport_1.getWsClient(`${apiBase}/forex`, apiKey); | ||
exports.getForexWebsocket = getForexWebsocket; |
@@ -1,2 +0,1 @@ | ||
import * as WebSocket from "ws"; | ||
export * from "./forex"; | ||
@@ -10,3 +9,3 @@ export * from "./stocks"; | ||
} | ||
export declare const websocketClient: (apiKey: string) => IWebsocketClient; | ||
export declare const websocketClient: (apiKey: string, apiBase?: string) => IWebsocketClient; | ||
export default websocketClient; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.websocketClient = void 0; | ||
const request_1 = require("../rest/transport/request"); | ||
@@ -10,10 +18,11 @@ const crypto_1 = require("./crypto"); | ||
const stocks_1 = require("./stocks"); | ||
__export(require("./forex")); | ||
__export(require("./stocks")); | ||
__export(require("./crypto")); | ||
exports.websocketClient = (apiKey) => ({ | ||
crypto: request_1.auth(apiKey, crypto_1.getCryptoWebsocket), | ||
forex: request_1.auth(apiKey, forex_1.getForexWebsocket), | ||
stocks: request_1.auth(apiKey, stocks_1.getStocksWebsocket) | ||
__exportStar(require("./forex"), exports); | ||
__exportStar(require("./stocks"), exports); | ||
__exportStar(require("./crypto"), exports); | ||
const websocketClient = (apiKey, apiBase) => ({ | ||
crypto: request_1.auth(apiKey, crypto_1.getCryptoWebsocket, apiBase), | ||
forex: request_1.auth(apiKey, forex_1.getForexWebsocket, apiBase), | ||
stocks: request_1.auth(apiKey, stocks_1.getStocksWebsocket, apiBase) | ||
}); | ||
exports.websocketClient = websocketClient; | ||
exports.default = exports.websocketClient; |
@@ -1,2 +0,2 @@ | ||
import * as WebSocket from "ws"; | ||
import { w3cwebsocket as Websocket } from "websocket"; | ||
export interface ITradeStockEvent { | ||
@@ -37,5 +37,6 @@ ev: string; | ||
a: number; | ||
z: number; | ||
s: number; | ||
e: number; | ||
} | ||
export declare const getStocksWebsocket: (apiKey: string) => WebSocket; | ||
export declare const getStocksWebsocket: (apiKey: string, apiBase?: string) => Websocket; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getStocksWebsocket = void 0; | ||
// Stocks TRADE: | ||
const transport_1 = require("../transport"); | ||
exports.getStocksWebsocket = (apiKey) => transport_1.getWsClient("wss://socket.polygon.io/stocks", apiKey); | ||
const getStocksWebsocket = (apiKey, apiBase) => transport_1.getWsClient(`${apiBase}/stocks`, apiKey); | ||
exports.getStocksWebsocket = getStocksWebsocket; |
@@ -1,2 +0,2 @@ | ||
import * as WebSocket from "ws"; | ||
export declare const getWsClient: (url: string, apiKey: string) => WebSocket; | ||
import { w3cwebsocket as Websocket } from "websocket"; | ||
export declare const getWsClient: (url: string, apiKey: string) => Websocket; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const WebSocket = require("ws"); | ||
exports.getWsClient = (url, apiKey) => { | ||
exports.getWsClient = void 0; | ||
const websocket_1 = require("websocket"); | ||
const getWsClient = (url, apiKey) => { | ||
if (!apiKey) { | ||
throw new Error("api key not provided."); | ||
} | ||
const ws = new WebSocket(url); | ||
ws.on("open", () => { | ||
const ws = new websocket_1.w3cwebsocket(url); | ||
ws.onopen = () => { | ||
ws.send(JSON.stringify({ action: "auth", params: apiKey })); | ||
}); | ||
}; | ||
return ws; | ||
}; | ||
exports.getWsClient = getWsClient; |
{ | ||
"name": "polygon.io", | ||
"version": "2.0.2", | ||
"description": "Node JS client for polygon.io api", | ||
"version": "2.1.0", | ||
"description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", | ||
"main": "lib/main.js", | ||
@@ -19,3 +19,6 @@ "types": "lib/main.d.ts", | ||
"keywords": [ | ||
"polygon.io" | ||
"polygon.io", | ||
"stock api", | ||
"forex api", | ||
"crypto api" | ||
], | ||
@@ -26,2 +29,6 @@ "contributors": [ | ||
"email": "julien@webeleon.dev" | ||
}, | ||
{ | ||
"name": "Katie Adams", | ||
"email": "katie@polygon.io" | ||
} | ||
@@ -35,16 +42,16 @@ ], | ||
"devDependencies": { | ||
"@types/chai": "^4.2.3", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^12.7.12", | ||
"@types/sinon": "^7.5.0", | ||
"@types/ws": "^7.2.0", | ||
"chai": "^4.2.0", | ||
"husky": "^3.0.9", | ||
"lint-staged": "^9.4.2", | ||
"mocha": "^6.2.1", | ||
"prettier": "1.18.2", | ||
"sinon": "^7.5.0", | ||
"ts-node": "^8.4.1", | ||
"typedoc": "^0.15.0", | ||
"typescript": "^3.6.4" | ||
"@types/chai": "^4.2.15", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^14.14.35", | ||
"@types/sinon": "^9.0.11", | ||
"@types/websocket": "^1.0.2", | ||
"chai": "^4.3.4", | ||
"husky": "^5.2.0", | ||
"lint-staged": "^10.5.4", | ||
"mocha": "^8.3.2", | ||
"prettier": "^2.2.1", | ||
"sinon": "^10.0.0", | ||
"ts-node": "^9.1.1", | ||
"typedoc": "^0.20.33", | ||
"typescript": "^4.2.3" | ||
}, | ||
@@ -63,4 +70,6 @@ "husky": { | ||
"dependencies": { | ||
"ws": "^7.2.1" | ||
"cross-fetch": "^3.1.2", | ||
"query-string": "^7.0.0", | ||
"websocket": "^1.0.33" | ||
} | ||
} |
# [polygon.io](https://polygon.io) | ||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | ||
[![CircleCI](https://circleci.com/gh/bassochette/polygon.io.svg?style=svg)](https://circleci.com/gh/bassochette/polygon.io) | ||
## This package has moved | ||
This package has moved to [@polygon.io/client-js](https://www.npmjs.com/package/@polygon.io/client-js) | ||
## Install | ||
```bash | ||
npm install --save polygon.io | ||
npm install --save @polygon.io/client-js | ||
``` | ||
@@ -19,3 +21,3 @@ | ||
```typescript | ||
import { polygonClient, restClient, websocketClient } from "polygon.io"; | ||
import { polygonClient, restClient, websocketClient } from "@polygon.io/client-js"; | ||
const rest = restClient("API KEY"); | ||
@@ -36,3 +38,3 @@ | ||
```typescript | ||
import { restClient } from "polygon.io"; | ||
import { restClient } from "@polygon.io/client-js"; | ||
@@ -47,3 +49,3 @@ const rest = restClient("api key"); | ||
```typescript | ||
import { referenceClient } from "polygon.io"; | ||
import { referenceClient } from "@polygon.io/client-js"; | ||
@@ -57,10 +59,10 @@ const reference = referenceClient("api key"); | ||
You can get preauthenticated [websocket clients](https://www.npmjs.com/package/ws) for the 3 topics. | ||
You can get preauthenticated [websocket clients](https://www.npmjs.com/package/websocket) for the 3 topics. | ||
```typescript | ||
import { websocketClient } from "polygon.io"; | ||
import { websocketClient } from "@polygon.io/client-js"; | ||
const stocksWS = websocketClient("api key").getStocksWebsocket(); | ||
stocksWs.on("message", raw => { | ||
stocksWs.onmessage = raw => { | ||
const message = JSON.parse(raw); | ||
@@ -67,0 +69,0 @@ switch (message.ev) { |
@@ -12,7 +12,7 @@ export * from "./rest"; | ||
export const polygonClient = (apiKey: string): IPolygonClient => ({ | ||
rest: restClient(apiKey), | ||
websockets: websocketClient(apiKey) | ||
export const polygonClient = (apiKey: string, restApiBase = "https://api.polygon.io", websocketApiBase = "wss://socket.polygon.io"): IPolygonClient => ({ | ||
rest: restClient(apiKey, restApiBase), | ||
websockets: websocketClient(apiKey, websocketApiBase) | ||
}); | ||
export default polygonClient; |
@@ -12,6 +12,7 @@ import { get } from "../transport/request"; | ||
ticker: string, | ||
query?: IAggregateQuery | ||
query?: IAggregateQuery, | ||
apiBase?: string | ||
): Promise<IAggResponseFormatted> => | ||
formatIAggResponseRaw( | ||
await get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query) | ||
await get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query, apiBase) | ||
); | ||
@@ -27,3 +28,4 @@ | ||
to: string, | ||
query?: IAggregateQuery | ||
query?: IAggregateQuery, | ||
apiBase?: string | ||
): Promise<IAggResponseFormatted> => | ||
@@ -34,3 +36,4 @@ formatIAggResponseRaw( | ||
apiKey, | ||
query | ||
query, | ||
apiBase | ||
) | ||
@@ -45,3 +48,4 @@ ); | ||
date: string, | ||
query?: IAggregateQuery | ||
query?: IAggregateQuery, | ||
apiBase?: string | ||
): Promise<IAggResponseFormatted> => | ||
@@ -52,4 +56,5 @@ formatIAggResponseRaw( | ||
apiKey, | ||
query | ||
query, | ||
apiBase | ||
) | ||
); |
@@ -13,3 +13,3 @@ //CF: https://polygon.io/docs/#!/Crypto/get_v1_meta_crypto_exchanges | ||
export const cryptoExchanges = (apiKey: string): Promise<ICryptoExchanges[]> => | ||
get(`/v1/meta/crypto-exchanges`, apiKey); | ||
export const cryptoExchanges = (apiKey: string, apiBase?: string): Promise<ICryptoExchanges[]> => | ||
get(`/v1/meta/crypto-exchanges`, apiKey, undefined, apiBase); |
@@ -13,7 +13,10 @@ import { get } from "../transport/request"; | ||
to: string, | ||
date: string | ||
date: string, | ||
apiBase?: string | ||
): Promise<ICryptoDailyOpenCloseFormatted> => { | ||
const raw: ICryptoDailyOpenCloseRaw = await get( | ||
`/v1/open-close/crypto/${from}/${to}/${date}`, | ||
apiKey | ||
apiKey, | ||
undefined, | ||
apiBase | ||
); | ||
@@ -20,0 +23,0 @@ const data: ICryptoDailyOpenCloseFormatted = { |
@@ -47,3 +47,4 @@ // CF: https://polygon.io/docs/#!/Crypto/get_v1_historic_crypto_from_to_date | ||
date: string, | ||
query: IHistoricCryptoTradeQuery = { limit: 100 } | ||
query: IHistoricCryptoTradeQuery = { limit: 100 }, | ||
apiBase?: string | ||
): Promise<IHistoricCryptoTradeFormatted> => { | ||
@@ -53,3 +54,4 @@ const raw: IHistoricCryptoTradeRaw = await get( | ||
apiKey, | ||
query | ||
query, | ||
apiBase | ||
); | ||
@@ -56,0 +58,0 @@ return { |
@@ -91,21 +91,22 @@ import { auth } from "../transport/request"; | ||
export const cryptoClient = (apiKey): ICryptoClient => ({ | ||
dailyOpenClose: auth(apiKey, cryptoDailyOpenClose), | ||
exchanges: auth(apiKey, cryptoExchanges), | ||
lastTradeForPair: auth(apiKey, lastTradeForCryptoPair), | ||
historicTrades: auth(apiKey, historicCryptoTrades), | ||
export const cryptoClient = (apiKey, apiBase?: string): ICryptoClient => ({ | ||
dailyOpenClose: auth(apiKey, cryptoDailyOpenClose, apiBase), | ||
exchanges: auth(apiKey, cryptoExchanges, apiBase), | ||
lastTradeForPair: auth(apiKey, lastTradeForCryptoPair, apiBase), | ||
historicTrades: auth(apiKey, historicCryptoTrades, apiBase), | ||
// snapshots | ||
snapshotSingleTicker: auth(apiKey, cryptoSnapshotSingleTicker), | ||
snapshotAllTickers: auth(apiKey, cryptoSnapshotAllTickers), | ||
snapshotGainersLosers: auth(apiKey, cryptoSnapshotGainersLosers), | ||
snapshotSingleTicker: auth(apiKey, cryptoSnapshotSingleTicker, apiBase), | ||
snapshotAllTickers: auth(apiKey, cryptoSnapshotAllTickers, apiBase), | ||
snapshotGainersLosers: auth(apiKey, cryptoSnapshotGainersLosers, apiBase), | ||
snapshotSingleTickerFullBook: auth( | ||
apiKey, | ||
cryptoSnapshotSingleTickerFullBook | ||
cryptoSnapshotSingleTickerFullBook, | ||
apiBase | ||
), | ||
// aggregates | ||
previousClose: auth(apiKey, cryptoPreviousClose), | ||
aggregates: auth(apiKey, cryptoAggregates), | ||
groupedDaily: auth(apiKey, cryptoGroupedDaily) | ||
previousClose: auth(apiKey, cryptoPreviousClose, apiBase), | ||
aggregates: auth(apiKey, cryptoAggregates, apiBase), | ||
groupedDaily: auth(apiKey, cryptoGroupedDaily, apiBase) | ||
}); | ||
export default cryptoClient; |
@@ -26,4 +26,5 @@ // CF: https://polygon.io/docs/#!/Crypto/get_v1_last_crypto_from_to | ||
from: string, | ||
to: string | ||
to: string, | ||
apiBase?: string | ||
): Promise<ILastTradeForACryptoPair> => | ||
get(`/v1/last/crypto/${from}/${to}`, apiKey); | ||
get(`/v1/last/crypto/${from}/${to}`, apiKey, undefined, apiBase); |
@@ -90,7 +90,10 @@ import { get } from "../transport/request"; | ||
export const cryptoSnapshotAllTickers = async ( | ||
apiKey: string | ||
apiKey: string, | ||
apiBase?: string | ||
): Promise<ICryptoSnapshotAllTickersFormatted> => { | ||
const raw: ICryptoSnapshotAllTickersRaw = await get( | ||
`/v2/snapshot/locale/global/markets/crypto/tickers`, | ||
apiKey | ||
apiKey, | ||
undefined, | ||
apiBase | ||
); | ||
@@ -106,7 +109,10 @@ return { | ||
apiKey: string, | ||
ticker: string | ||
ticker: string, | ||
apiBase?: string | ||
): Promise<ICryptoSnapshotSingleTickerFormatted> => { | ||
const raw: ICryptoSnapshotSingleTickerRaw = await get( | ||
`/v2/snapshot/locale/global/markets/crypto/tickers/${ticker}`, | ||
apiKey | ||
apiKey, | ||
undefined, | ||
apiBase | ||
); | ||
@@ -122,7 +128,10 @@ return { | ||
apiKey: string, | ||
direction: string = "gainers" | ||
direction: string = "gainers", | ||
apiBase?: string | ||
): Promise<ICryptoSnapshotAllTickersFormatted> => { | ||
const raw: ICryptoSnapshotAllTickersRaw = await get( | ||
`/v2/snapshot/locale/global/markets/crypto/${direction}`, | ||
apiKey | ||
apiKey, | ||
undefined, | ||
apiBase | ||
); | ||
@@ -203,9 +212,12 @@ return { | ||
apiKey: string, | ||
ticker: string | ||
ticker: string, | ||
apiBase?: string | ||
): Promise<ICryptoSingleTickerFullBookFormatted> => { | ||
const raw: ICryptoSingleTickerFullBookRaw = await get( | ||
`/v2/snapshot/locale/global/markets/crypto/tickers/${ticker}/book`, | ||
apiKey | ||
apiKey, | ||
undefined, | ||
apiBase | ||
); | ||
return formatICryptoSingleTickerFullBookRaw(raw); | ||
}; |
@@ -12,6 +12,7 @@ import { get } from "../transport/request"; | ||
ticker: string, | ||
query?: IAggregateQuery | ||
query?: IAggregateQuery, | ||
apiBase?: string | ||
): Promise<IAggResponseFormatted> => | ||
formatIAggResponseRaw( | ||
await get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query) | ||
await get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query, apiBase) | ||
); | ||
@@ -27,3 +28,4 @@ | ||
to: string, | ||
query?: IAggregateQuery | ||
query?: IAggregateQuery, | ||
apiBase?: string | ||
): Promise<IAggResponseFormatted> => | ||
@@ -34,3 +36,4 @@ formatIAggResponseRaw( | ||
apiKey, | ||
query | ||
query, | ||
apiBase | ||
) | ||
@@ -45,3 +48,4 @@ ); | ||
date: string, | ||
query?: IAggregateQuery | ||
query?: IAggregateQuery, | ||
apiBase?: string | ||
): Promise<IAggResponseFormatted> => | ||
@@ -52,4 +56,5 @@ formatIAggResponseRaw( | ||
apiKey, | ||
query | ||
query, | ||
apiBase | ||
) | ||
); |
@@ -66,6 +66,7 @@ // CF: https://polygon.io/docs/#!/Forex--Currencies/get_v1_historic_forex_from_to_date | ||
date: string, | ||
query: IHistoricForexTicksQuery | ||
query: IHistoricForexTicksQuery, | ||
apiBase?: string | ||
): Promise<IHistoricForexTicksFormatted> => | ||
formatIHistoricForexTicksRaw( | ||
await get(`/v1/historic/forex/${from}/${to}/${date}`, apiKey, query) | ||
await get(`/v1/historic/forex/${from}/${to}/${date}`, apiKey, query, apiBase) | ||
); |
@@ -82,15 +82,15 @@ import { auth } from "../transport/request"; | ||
export const forexClient = (apiKey: string): IForexClient => ({ | ||
lastQuoteForCurrencyPair: auth(apiKey, lastQuoteForCurrencyPair), | ||
historicTicks: auth(apiKey, historicForexTicks), | ||
realTimeCurrencyConversion: auth(apiKey, realTimeCurrencyConversion), | ||
export const forexClient = (apiKey: string, apiBase?: string): IForexClient => ({ | ||
lastQuoteForCurrencyPair: auth(apiKey, lastQuoteForCurrencyPair, apiBase), | ||
historicTicks: auth(apiKey, historicForexTicks, apiBase), | ||
realTimeCurrencyConversion: auth(apiKey, realTimeCurrencyConversion, apiBase), | ||
// aggregates | ||
previousClose: auth(apiKey, forexPreviousClose), | ||
aggregates: auth(apiKey, forexAggregates), | ||
groupedDaily: auth(apiKey, forexGroupedDaily), | ||
previousClose: auth(apiKey, forexPreviousClose, apiBase), | ||
aggregates: auth(apiKey, forexAggregates, apiBase), | ||
groupedDaily: auth(apiKey, forexGroupedDaily, apiBase), | ||
// snapshots | ||
snapshotAllTickers: auth(apiKey, forexSnapshotAllTickers), | ||
snapshotGainersLosers: auth(apiKey, forexSnapshotGainersLosers) | ||
snapshotAllTickers: auth(apiKey, forexSnapshotAllTickers, apiBase), | ||
snapshotGainersLosers: auth(apiKey, forexSnapshotGainersLosers, apiBase) | ||
}); | ||
export default forexClient; |
@@ -20,4 +20,5 @@ // CF: https://polygon.io/docs/#!/Forex--Currencies/get_v1_last_quote_currencies_from_to | ||
from: string, | ||
to: string | ||
to: string, | ||
apiBase?: string | ||
): Promise<ILastQuoteForCurrencyPair> => | ||
get(`/v1/last_quote/currencies/${from}/${to}`, apiKey); | ||
get(`/v1/last_quote/currencies/${from}/${to}`, apiKey, undefined, apiBase); |
@@ -28,4 +28,5 @@ // CF: https://polygon.io/docs/#!/Forex--Currencies/get_v1_conversion_from_to | ||
to: string, | ||
query: IRealTimeConversionQuery | ||
query: IRealTimeConversionQuery, | ||
apiBase?: string | ||
): Promise<IRealTimeConversion> => | ||
get(`/v1/conversion/${from}/${to}`, apiKey, query); | ||
get(`/v1/conversion/${from}/${to}`, apiKey, query, apiBase); |
@@ -84,6 +84,7 @@ import { formatIV1ForexRaw, IV1ForexRaw } from "./historicForexTicks"; | ||
export const forexSnapshotAllTickers = async ( | ||
apiKey: string | ||
apiKey: string, | ||
apiBase?: string | ||
): Promise<IForexSnapshotAllTickersResponseFormatted> => | ||
formatIForexSnapshotAllTickersResponseRaw( | ||
await get(`/v2/snapshot/locale/global/markets/forex/tickers`, apiKey) | ||
await get(`/v2/snapshot/locale/global/markets/forex/tickers`, apiKey, undefined, apiBase) | ||
); | ||
@@ -94,6 +95,7 @@ | ||
apiKey: string, | ||
direction: string = "gainers" | ||
direction: string = "gainers", | ||
apiBase?: string | ||
): Promise<IForexSnapshotAllTickersResponseFormatted> => | ||
formatIForexSnapshotAllTickersResponseRaw( | ||
await get(`/v2/snapshot/locale/global/markets/forex/${direction}`, apiKey) | ||
await get(`/v2/snapshot/locale/global/markets/forex/${direction}`, apiKey, undefined, apiBase) | ||
); |
@@ -17,9 +17,9 @@ import { cryptoClient, ICryptoClient } from "./crypto"; | ||
export const restClient = (apiKey): IRestClient => ({ | ||
crypto: cryptoClient(apiKey), | ||
forex: forexClient(apiKey), | ||
stocks: stocksClient(apiKey), | ||
reference: referenceClient(apiKey) | ||
export const restClient = (apiKey, apiBase?: string): IRestClient => ({ | ||
crypto: cryptoClient(apiKey, apiBase), | ||
forex: forexClient(apiKey, apiBase), | ||
stocks: stocksClient(apiKey, apiBase), | ||
reference: referenceClient(apiKey, apiBase) | ||
}); | ||
export default restClient; |
@@ -53,16 +53,16 @@ import { auth } from "../transport/request"; | ||
export const referenceClient = (apiKey: string): IReferenceClient => ({ | ||
locales: auth(apiKey, locales), | ||
markets: auth(apiKey, markets), | ||
marketHolydays: auth(apiKey, marketHolydays), | ||
marketStatus: auth(apiKey, marketStatus), | ||
stockDividends: auth(apiKey, stockDividends), | ||
stockFinancials: auth(apiKey, stockFinancials), | ||
stockSplits: auth(apiKey, stockSplits), | ||
tickerDetails: auth(apiKey, tickerDetails), | ||
tickerNews: auth(apiKey, tickerNews), | ||
tickers: auth(apiKey, tickers), | ||
tickerTypes: auth(apiKey, tickerTypes) | ||
export const referenceClient = (apiKey: string, apiBase?: string): IReferenceClient => ({ | ||
locales: auth(apiKey, locales, apiBase), | ||
markets: auth(apiKey, markets, apiBase), | ||
marketHolydays: auth(apiKey, marketHolydays, apiBase), | ||
marketStatus: auth(apiKey, marketStatus, apiBase), | ||
stockDividends: auth(apiKey, stockDividends, apiBase), | ||
stockFinancials: auth(apiKey, stockFinancials, apiBase), | ||
stockSplits: auth(apiKey, stockSplits, apiBase), | ||
tickerDetails: auth(apiKey, tickerDetails, apiBase), | ||
tickerNews: auth(apiKey, tickerNews, apiBase), | ||
tickers: auth(apiKey, tickers, apiBase), | ||
tickerTypes: auth(apiKey, tickerTypes, apiBase) | ||
}); | ||
export default referenceClient; |
@@ -14,3 +14,3 @@ // CF: https://polygon.io/docs/#!/Reference/get_v2_reference_locales | ||
export const locales = async (apiKeys: string): Promise<ILocalesResponse> => | ||
get("/v2/reference/locales", apiKeys); | ||
export const locales = async (apiKeys: string, apiBase?: string): Promise<ILocalesResponse> => | ||
get("/v2/reference/locales", apiKeys, undefined, apiBase); |
@@ -14,3 +14,4 @@ // CF: https://polygon.io/docs/#!/Reference/get_v1_marketstatus_upcoming | ||
export const marketHolydays = async ( | ||
apiKey: string | ||
): Promise<IMarketHolyday[]> => get("/v1/marketstatus/upcoming", apiKey); | ||
apiKey: string, | ||
apiBase?: string | ||
): Promise<IMarketHolyday[]> => get("/v1/marketstatus/upcoming", apiKey, undefined, apiBase); |
@@ -14,3 +14,3 @@ // CF: https://polygon.io/docs/#!/Reference/get_v2_reference_markets | ||
export const markets = async (apiKey: string): Promise<IMarketResponse> => | ||
get("/v2/reference/markets", apiKey); | ||
export const markets = async (apiKey: string, apiBase?: string): Promise<IMarketResponse> => | ||
get("/v2/reference/markets", apiKey, undefined, apiBase); |
@@ -22,3 +22,3 @@ // CF: https://polygon.io/docs/#!/Reference/get_v1_marketstatus_now | ||
export const marketStatus = async (apiKey: string): Promise<IMarketStatus> => | ||
get("/v1/marketstatus/now", apiKey); | ||
export const marketStatus = async (apiKey: string, apiBase?: string): Promise<IMarketStatus> => | ||
get("/v1/marketstatus/now", apiKey, undefined, apiBase); |
@@ -23,4 +23,5 @@ // CF: https://polygon.io/docs/#!/Reference/get_v2_reference_splits_symbol | ||
apiKey: string, | ||
symbol: string | ||
symbol: string, | ||
apiBase?: string | ||
): Promise<IStockDividendsResults> => | ||
get(`/v2/reference/dividends/${symbol}`, apiKey); | ||
get(`/v2/reference/dividends/${symbol}`, apiKey, undefined, apiBase); |
@@ -132,4 +132,5 @@ // CF: https://polygon.io/docs/#!/Reference/get_v2_reference_financials_symbol | ||
symbol: string, | ||
query?: IStockFinancialQuery | ||
query?: IStockFinancialQuery, | ||
apiBase?: string | ||
): Promise<IStockFinancialResults[]> => | ||
get(`/v2/reference/financials/${symbol}`, apiKey, query); | ||
get(`/v2/reference/financials/${symbol}`, apiKey, query, apiBase); |
@@ -22,4 +22,5 @@ // CF: https://polygon.io/docs/#!/Reference/get_v2_reference_splits_symbol | ||
apiKey: string, | ||
symbol: string | ||
symbol: string, | ||
apiBase?: string | ||
): Promise<IStockSplitsResults> => | ||
get(`/v2/reference/splits/${symbol}`, apiKey); | ||
get(`/v2/reference/splits/${symbol}`, apiKey, undefined, apiBase); |
@@ -56,7 +56,10 @@ // CF: https://polygon.io/docs/#!/Reference/get_v1_meta_symbols_symbol_company | ||
apiKey: string, | ||
symbol: string | ||
symbol: string, | ||
apiBase?: string | ||
): Promise<ITickerDetailsFormatted> => { | ||
const raw: ITickerDetailsRaw = await get( | ||
`/v1/meta/symbols/${symbol}/company`, | ||
apiKey | ||
apiKey, | ||
undefined, | ||
apiBase | ||
); | ||
@@ -63,0 +66,0 @@ |
@@ -22,4 +22,5 @@ // CF: https://polygon.io/docs/#!/Reference/get_v1_meta_symbols_symbol_news | ||
symbol: string, | ||
query?: ITickerNewsQuery | ||
query?: ITickerNewsQuery, | ||
apiBase?: string | ||
): Promise<ITickerNews[]> => | ||
get(`/v1/meta/symbols/${symbol}/news`, apiKey, query); | ||
get(`/v1/meta/symbols/${symbol}/news`, apiKey, query, apiBase); |
@@ -31,6 +31,7 @@ // CF: https://polygon.io/docs/#!/Reference/get_v2_reference_tickers | ||
apiKey: string, | ||
query?: ITickersQuery | ||
query?: ITickersQuery, | ||
apiBase?: string | ||
): Promise<ITickers[]> => { | ||
const path: string = "/v2/reference/tickers"; | ||
return get(path, apiKey, query); | ||
return get(path, apiKey, query, apiBase); | ||
}; |
@@ -9,3 +9,3 @@ // CF: https://polygon.io/docs/#!/Reference/get_v2_reference_types | ||
export const tickerTypes = async (apiKeys: string): Promise<ITickerTypes> => | ||
get("/v2/reference/types", apiKeys); | ||
export const tickerTypes = async (apiKeys: string, apiBase?: string): Promise<ITickerTypes> => | ||
get("/v2/reference/types", apiKeys, undefined, apiBase); |
@@ -74,6 +74,7 @@ import { get, IPolygonQuery } from "../transport/request"; | ||
ticker: string, | ||
query?: IAggregateQuery | ||
query?: IAggregateQuery, | ||
apiBase?: string | ||
): Promise<IAggResponseFormatted> => | ||
formatIAggResponseRaw( | ||
await get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query) | ||
await get(`/v2/aggs/ticker/${ticker}/prev`, apiKey, query, apiBase) | ||
); | ||
@@ -89,3 +90,4 @@ | ||
to: string, | ||
query?: IAggregateQuery | ||
query?: IAggregateQuery, | ||
apiBase?: string | ||
): Promise<IAggResponseFormatted> => | ||
@@ -96,3 +98,4 @@ formatIAggResponseRaw( | ||
apikey, | ||
query | ||
query, | ||
apiBase | ||
) | ||
@@ -107,3 +110,4 @@ ); | ||
date: string, | ||
query?: IAggregateQuery | ||
query?: IAggregateQuery, | ||
apiBase?: string | ||
): Promise<IAggResponseFormatted> => | ||
@@ -114,4 +118,5 @@ formatIAggResponseRaw( | ||
apiKey, | ||
query | ||
query, | ||
apiBase | ||
) | ||
); |
@@ -10,4 +10,5 @@ // CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_meta_conditions_ticktype | ||
apiKeys: string, | ||
ticktype: string = "trades" | ||
ticktype: string = "trades", | ||
apiBase?: string | ||
): Promise<IConditionMappings> => | ||
get(`/v1/meta/conditions/${ticktype}`, apiKeys); | ||
get(`/v1/meta/conditions/${ticktype}`, apiKeys, undefined, apiBase); |
@@ -25,3 +25,4 @@ // CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_open_close_symbol_date | ||
symbol: string, | ||
date: string | ||
): Promise<IDailyOpenClose> => get(`/v1/open-close/${symbol}/${date}`, apiKey); | ||
date: string, | ||
apiBase?: string | ||
): Promise<IDailyOpenClose> => get(`/v1/open-close/${symbol}/${date}`, apiKey, undefined, apiBase); |
@@ -27,4 +27,5 @@ // CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_meta_exchanges | ||
export const exchanges = async ( | ||
apiKey: string | ||
apiKey: string, | ||
apiBase?: string | ||
): Promise<IExchangeFormatted[]> => | ||
(await get(`/v1/meta/exchanges`, apiKey)).map(formatIExchangeRaw); | ||
(await get(`/v1/meta/exchanges`, apiKey, undefined, apiBase)).map(formatIExchangeRaw); |
@@ -124,22 +124,22 @@ import { auth } from "../transport/request"; | ||
export const stocksClient = (apiKey: string): IStocksClient => ({ | ||
conditionMappings: auth(apiKey, conditionMappings), | ||
dailyOpenClose: auth(apiKey, dailyOpenClose), | ||
exchanges: auth(apiKey, exchanges), | ||
lastQuoteForSymbol: auth(apiKey, lastQuoteForSymbol), | ||
lastTradeForSymbol: auth(apiKey, lastTradeForSymbol), | ||
v1HistoricQuotes: auth(apiKey, v1HistoricQuotes), | ||
v1HistoricTrades: auth(apiKey, v1HistoricTrades), | ||
v2HistoricQuotes: auth(apiKey, v2HistoricQuotes), | ||
v2HistoricTrades: auth(apiKey, v2HistoricTrades), | ||
export const stocksClient = (apiKey: string, apiBase?: string): IStocksClient => ({ | ||
conditionMappings: auth(apiKey, conditionMappings, apiBase), | ||
dailyOpenClose: auth(apiKey, dailyOpenClose, apiBase), | ||
exchanges: auth(apiKey, exchanges, apiBase), | ||
lastQuoteForSymbol: auth(apiKey, lastQuoteForSymbol, apiBase), | ||
lastTradeForSymbol: auth(apiKey, lastTradeForSymbol, apiBase), | ||
v1HistoricQuotes: auth(apiKey, v1HistoricQuotes, apiBase), | ||
v1HistoricTrades: auth(apiKey, v1HistoricTrades, apiBase), | ||
v2HistoricQuotes: auth(apiKey, v2HistoricQuotes, apiBase), | ||
v2HistoricTrades: auth(apiKey, v2HistoricTrades, apiBase), | ||
// snapshot | ||
snapshotAllTickers: auth(apiKey, snapshotAllTickers), | ||
snapshotSingleTicker: auth(apiKey, snapshotSingleTicker), | ||
snapshotGainersLosers: auth(apiKey, snapshotGainersLosers), | ||
snapshotAllTickers: auth(apiKey, snapshotAllTickers, apiBase), | ||
snapshotSingleTicker: auth(apiKey, snapshotSingleTicker, apiBase), | ||
snapshotGainersLosers: auth(apiKey, snapshotGainersLosers, apiBase), | ||
// aggregates | ||
previousClose: auth(apiKey, stocksPreviousClose), | ||
aggregates: auth(apiKey, stocksAggregates), | ||
groupedDaily: auth(apiKey, stocksGroupedDaily) | ||
previousClose: auth(apiKey, stocksPreviousClose, apiBase), | ||
aggregates: auth(apiKey, stocksAggregates, apiBase), | ||
groupedDaily: auth(apiKey, stocksGroupedDaily, apiBase) | ||
}); | ||
export default stocksClient; |
@@ -21,3 +21,4 @@ // CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_last_quote_stocks_symbol | ||
apiKey: string, | ||
symbol: string | ||
): Promise<ILastQuoteResult> => get(`/v1/last_quote/stocks/${symbol}`, apiKey); | ||
symbol: string, | ||
apiBase?: string | ||
): Promise<ILastQuoteResult> => get(`/v1/last_quote/stocks/${symbol}`, apiKey, undefined, apiBase); |
@@ -24,3 +24,4 @@ // CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_last_stocks_symbol | ||
apiKey: string, | ||
symbol: string | ||
): Promise<ILastTradeResult> => get(`/v1/last/stocks/${symbol}`, apiKey); | ||
symbol: string, | ||
apiBase?: string | ||
): Promise<ILastTradeResult> => get(`/v1/last/stocks/${symbol}`, apiKey, undefined, apiBase); |
@@ -118,6 +118,7 @@ import { get } from "../transport/request"; | ||
export const snapshotAllTickers = async ( | ||
apiKey: string | ||
apiKey: string, | ||
apiBase?: string | ||
): Promise<ISnapshotAllTickersResultFormatted> => | ||
formatISnapshotAllTickersResultRaw( | ||
await get(`/v2/snapshot/locale/us/markets/stocks/tickers`, apiKey) | ||
await get(`/v2/snapshot/locale/us/markets/stocks/tickers`, apiKey, undefined, apiBase) | ||
); | ||
@@ -143,6 +144,7 @@ | ||
apiKey: string, | ||
ticker: string | ||
ticker: string, | ||
apiBase?: string | ||
): Promise<ISnapshotSingleTickerResultFormatted> => | ||
formatISnapshotSingleTickerResultRaw( | ||
await get(`/v2/snapshot/locale/us/markets/stocks/tickers/${ticker}`, apiKey) | ||
await get(`/v2/snapshot/locale/us/markets/stocks/tickers/${ticker}`, apiKey, undefined, apiBase) | ||
); | ||
@@ -161,6 +163,7 @@ | ||
apiKey: string, | ||
direction: string = "gainers" | ||
direction: string = "gainers", | ||
apiBase?: string | ||
): Promise<ISnapshotGainersLosersResultFormatted> => | ||
formatISnapshotAllTickersResultRaw( | ||
await get(`/v2/snapshot/locale/us/markets/stocks/${direction}`, apiKey) | ||
await get(`/v2/snapshot/locale/us/markets/stocks/${direction}`, apiKey, undefined, apiBase) | ||
); |
@@ -93,6 +93,7 @@ // CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_historic_quotes_symbol_date | ||
date: string, | ||
query?: IV1HistoricQuotesQuery | ||
query?: IV1HistoricQuotesQuery, | ||
apiBase?: string | ||
): Promise<IV1HistoricQuotesResultFormatted> => | ||
formatIV1HistoricQuotesResultRaw( | ||
await get(`/v1/historic/quotes/${symbol}/${date}`, apiKey, query) | ||
await get(`/v1/historic/quotes/${symbol}/${date}`, apiKey, query, apiBase) | ||
); |
@@ -93,6 +93,7 @@ // CF: https://polygon.io/docs/#!/Stocks--Equities/get_v1_historic_trades_symbol_date | ||
date: string, | ||
query?: IV1HistoricTradesQuery | ||
query?: IV1HistoricTradesQuery, | ||
apiBase?: string | ||
): Promise<IV1HistoricTradesResultFormatted> => | ||
formatIV1HistoricTradesResultRaw( | ||
await get(`/v1/historic/trades/${symbol}/${date}`, apiKey, query) | ||
await get(`/v1/historic/trades/${symbol}/${date}`, apiKey, query, apiBase) | ||
); |
@@ -100,6 +100,7 @@ // CF: https://polygon.io/docs/#!/Stocks--Equities/get_v2_ticks_stocks_nbbo_ticker_date | ||
date: string, | ||
query?: IV2HistoricQuotesQuery | ||
query?: IV2HistoricQuotesQuery, | ||
apiBase?: string | ||
): Promise<IV2HistoricQuotesResultFormatted> => | ||
formatIV2HistoricQuotesResultRaw( | ||
await get(`/v2/ticks/stocks/nbbo/${symbol}/${date}`, apiKey, query) | ||
await get(`/v2/ticks/stocks/nbbo/${symbol}/${date}`, apiKey, query, apiBase) | ||
); |
@@ -87,6 +87,7 @@ // CF: https://polygon.io/docs/#!/Stocks--Equities/get_v2_ticks_stocks_trades_ticker_date | ||
date: string, | ||
query?: IV2HistoricTradesQuery | ||
query?: IV2HistoricTradesQuery, | ||
apiBase?: string | ||
): Promise<IV2HistoricTradesResultFormatted> => | ||
formatIV2HistoricTradeResultRaw( | ||
await get(`/v2/ticks/stocks/trades/${symbol}/${date}`, apiKey, query) | ||
await get(`/v2/ticks/stocks/trades/${symbol}/${date}`, apiKey, query, apiBase) | ||
); |
@@ -1,6 +0,6 @@ | ||
import * as https from "https"; | ||
import * as querystring from "querystring"; | ||
import fetch from "cross-fetch"; | ||
import { stringify } from "query-string"; | ||
export interface IPolygonQuery { | ||
[key: string]: string | number | boolean; | ||
[key: string]: string | number | boolean | undefined; | ||
} | ||
@@ -12,42 +12,31 @@ | ||
export const auth = (apiKey, func) => (...args) => func(apiKey, ...args); | ||
export const auth = (apiKey, func: Function, apiBase: string) => (...args) => func(apiKey, ...args, apiBase); | ||
export const get = ( | ||
export const get = async ( | ||
path: string, | ||
apiKey: string = "invalid", | ||
query?: IPolygonQuery | ||
): Promise<any> => | ||
new Promise((resolve, reject) => { | ||
if (!apiKey) { | ||
throw new Error("API KEY not configured..."); | ||
} | ||
query?: IPolygonQuery, | ||
apiBase?: string | ||
): Promise<any> => { | ||
if (!apiKey) { | ||
throw new Error("API KEY not configured..."); | ||
} | ||
const authenticatedQuery: IPolygonQueryWithCredentials = { | ||
...query, | ||
apiKey | ||
}; | ||
const authenticatedQuery: IPolygonQueryWithCredentials = { | ||
...query, | ||
apiKey | ||
}; | ||
const options = { | ||
protocol: "https:", | ||
method: "GET", | ||
host: "api.polygon.io", | ||
path: path + "?" + querystring.encode(authenticatedQuery) | ||
}; | ||
const queryString = stringify(authenticatedQuery, { encode: true }); | ||
const request = https.request(options, (response: any) => { | ||
let data = ""; | ||
response.on("data", function(chunk: string) { | ||
data += chunk; | ||
}); | ||
const url = `${apiBase}${path}?${queryString}`; | ||
response.on("end", function() { | ||
resolve(JSON.parse(data)); | ||
}); | ||
}); | ||
const response = await fetch(url); | ||
request.on("error", (error: any) => { | ||
reject(error); | ||
}); | ||
if (response.status >= 400) { | ||
const message = await response.text(); | ||
throw new Error(message); | ||
} | ||
request.end(); | ||
}); | ||
return response.json(); | ||
}; |
// Crypto QUOTE: | ||
import * as WebSocket from "ws"; | ||
import { w3cwebsocket as Websocket } from "websocket"; | ||
import { getWsClient } from "../transport"; | ||
@@ -73,3 +73,3 @@ | ||
export const getCryptoWebsocket = (apiKey: string): WebSocket => | ||
getWsClient("wss://socket.polygon.io/crypto", apiKey); | ||
export const getCryptoWebsocket = (apiKey: string, apiBase?: string): Websocket => | ||
getWsClient(`${apiBase}/crypto`, apiKey); |
// Forex QUOTE: | ||
import { getWsClient } from "../transport"; | ||
import * as WebSocket from "ws"; | ||
import { w3cwebsocket as Websocket } from "websocket"; | ||
@@ -26,3 +26,3 @@ export interface IQuoteForexEvent { | ||
export const getForexWebsocket = (apiKey: string): WebSocket => | ||
getWsClient("wss://socket.polygon.io/forex", apiKey); | ||
export const getForexWebsocket = (apiKey: string, apiBase?: string): Websocket => | ||
getWsClient(`${apiBase}/forex`, apiKey); |
import { auth } from "../rest/transport/request"; | ||
import * as WebSocket from "ws"; | ||
@@ -18,8 +17,8 @@ import { getCryptoWebsocket } from "./crypto"; | ||
export const websocketClient = (apiKey: string): IWebsocketClient => ({ | ||
crypto: auth(apiKey, getCryptoWebsocket), | ||
forex: auth(apiKey, getForexWebsocket), | ||
stocks: auth(apiKey, getStocksWebsocket) | ||
export const websocketClient = (apiKey: string, apiBase?: string): IWebsocketClient => ({ | ||
crypto: auth(apiKey, getCryptoWebsocket, apiBase), | ||
forex: auth(apiKey, getForexWebsocket, apiBase), | ||
stocks: auth(apiKey, getStocksWebsocket, apiBase) | ||
}); | ||
export default websocketClient; |
// Stocks TRADE: | ||
import { getWsClient } from "../transport"; | ||
import * as WebSocket from "ws"; | ||
import { w3cwebsocket as Websocket } from "websocket"; | ||
@@ -44,2 +44,3 @@ export interface ITradeStockEvent { | ||
a: number; // Tick Average / VWAP Price | ||
z: number; // Tick Average Trade Size | ||
s: number; // Tick Start Timestamp ( Unix MS ) | ||
@@ -49,3 +50,3 @@ e: number; // Tick End Timestamp ( Unix MS ) | ||
export const getStocksWebsocket = (apiKey: string): WebSocket => | ||
getWsClient("wss://socket.polygon.io/stocks", apiKey); | ||
export const getStocksWebsocket = (apiKey: string, apiBase?: string): Websocket => | ||
getWsClient(`${apiBase}/stocks`, apiKey); |
@@ -1,13 +0,15 @@ | ||
import * as WebSocket from "ws"; | ||
import { w3cwebsocket as Websocket } from "websocket"; | ||
export const getWsClient = (url: string, apiKey: string): WebSocket => { | ||
export const getWsClient = (url: string, apiKey: string): Websocket => { | ||
if (!apiKey) { | ||
throw new Error("api key not provided."); | ||
} | ||
const ws = new WebSocket(url); | ||
ws.on("open", () => { | ||
const ws = new Websocket(url); | ||
ws.onopen = () => { | ||
ws.send(JSON.stringify({ action: "auth", params: apiKey })); | ||
}); | ||
}; | ||
return ws; | ||
}; |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
204413
150
5373
82
3
3
+ Addedcross-fetch@^3.1.2
+ Addedquery-string@^7.0.0
+ Addedwebsocket@^1.0.33
+ Addedbufferutil@4.0.8(transitive)
+ Addedcross-fetch@3.1.8(transitive)
+ Addedd@1.0.2(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedext@1.7.0(transitive)
+ Addedfilter-obj@1.1.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedms@2.0.0(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addednode-gyp-build@4.8.1(transitive)
+ Addedquery-string@7.1.3(transitive)
+ Addedsplit-on-first@1.1.0(transitive)
+ Addedstrict-uri-encode@2.0.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedtype@2.7.2(transitive)
+ Addedtypedarray-to-buffer@3.1.5(transitive)
+ Addedutf-8-validate@5.0.10(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwebsocket@1.0.35(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedyaeti@0.0.6(transitive)
- Removedws@^7.2.1
- Removedws@7.5.9(transitive)