8000 Merge 11ab985867175ab03b013407c650a983c90ee9f1 into a98bb77c02314ae19… · polygon-io/client-js@8000e9f · GitHub
[go: up one dir, main page]

Skip to content

Commit 8000e9f

Browse files
authored
Merge 11ab985 into a98bb77
2 parents a98bb77 + 11ab985 commit 8000e9f

19 files changed

+533
-32
lines changed

package-lock.json

+78-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"mocha": "^9.1.3",
6060
"prettier": "^2.5.1",
6161
"sinon": "^12.0.1",
62-
"ts-node": "^10.4.0",
62+
"ts-node": "^10.9.1",
6363
"typedoc": "^0.22.10",
6464
"typescript": "^4.5.2"
6565
},

src/rest/index.test.ts

+3
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ describe("[EXPORT] REST Endpoints", () => {
2020
it("> stocks", () => {
2121
rest.stocks.should.be.an("object");
2222
});
23+
it("> indices", () => {
24+
rest.indices.should.be.an("object");
25+
});
2326
});

src/rest/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ import { forexClient, IForexClient } from "./forex/index.js";
33
import { referenceClient, IReferenceClient } from "./reference/index.js";
44
import { optionsClient, IOptionsClient } from "./options/index.js";
55
import { stocksClient, IStocksClient } from "./stocks/index.js";
6+
import { indicesClient, IIndicesClient } from "./indices/index.js";
67
import { IRequestOptions } from "./transport/request.js";
78
export * from "./crypto/index.js";
89
export * from "./forex/index.js";
910
export * from "./reference/index.js";
1011
export * from "./options/index.js";
1112
export * from "./stocks/index.js";
13+
export * from "./indices/index.js";
1214

1315
export interface IRestClient {
1416
crypto: ICryptoClient;
1517
forex: IForexClient;
1618
reference: IReferenceClient;
1719
options: IOptionsClient;
1820
stocks: IStocksClient;
21+
indices: IIndicesClient;
1922
}
2023

2124
export const restClient = (apiKey, apiBase?: string, options?: IRequestOptions): IRestClient => ({
@@ -24,6 +27,7 @@ export const restClient = (apiKey, apiBase?: string, options?: IRequestOptions):
2427
reference: referenceClient(apiKey, apiBase, options),
2528
options: optionsClient(apiKey, apiBase, options),
2629
stocks: stocksClient(apiKey, apiBase, options),
30+
indices: indicesClient(apiKey, apiBase, options),
2731
});
2832

2933
export default restClient;

src/rest/indices/aggregates.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// CF: https://polygon.io/docs/indices/get_v2_aggs_ticker__indexTicker__range__multiplier___timespan___from___to
2+
3+
import { IAggsQuery, IAggs } from "../stocks/aggregates.js";
4+
import { IGet, IRequestOptions } from "../transport/request.js";
5+
6+
export const aggregates = async (
7+
get: IGet,
8+
ticker: string,
9+
multiplier: number,
10+
timespan: string,
11+
from: string,
12+
to: string,
13+
query?: IAggsQuery,
14+
options?: IRequestOptions
15+
): Promise<IAggs> =>
16+
get(
17+
`/v2/aggs/ticker/${ticker}/range/${multiplier}/${timespan}/${from}/${to}`,
18+
query,
19+
options
20+
);

src/rest/indices/dailyOpenClose.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// CF: https://polygon.io/docs/indices/get_v1_open-close__stocksticker___date
2+
3+
import { IDailyOpenClose, IDailyOpenCloseQuery } from "../stocks/dailyOpenClose.js";
4+
import { IGet, IRequestOptions } from "../transport/request.js";
5+
6+
export const dailyOpenClose = async (
7+
get: IGet,
8+
symbol: string,
9+
date: string,
10+
query?: IDailyOpenCloseQuery,
11+
options?: IRequestOptions
12+
): Promise<IDailyOpenClose> =>
13+
get(`/v1/open-close/${symbol}/${date}`, query, options);

src/rest/indices/ema.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// CF: https://polygon.io/docs/indices/get_v1_indicators_ema__indexticker
2+
3+
import { ITechnicalIndicatorsQuery } from "../stocks/sma";
4+
import { IEma } from "../stocks/ema";
5+
import { IGet, IRequestOptions } from "../transport/request.js";
6+
7+
export { IEma } from '../stocks/ema';
8+
9+
export const ema = async (
10+
get: IGet,
11+
symbol: string,
12+
query?: ITechnicalIndicatorsQuery,
13+
options?: IRequestOptions
14+
): Promise<IEma> => get(`/v1/indicators/ema/${symbol}`, query, options);

0 commit comments

Comments
 (0)
0