-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathtrendingSymbols.ts
70 lines (63 loc) · 1.67 KB
/
trendingSymbols.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import type {
ModuleOptions,
ModuleOptionsWithValidateTrue,
ModuleOptionsWithValidateFalse,
ModuleThis,
} from "../lib/moduleCommon.js";
export interface TrendingSymbol {
[key: string]: any;
symbol: string;
}
export interface TrendingSymbolsResult {
[key: string]: any;
count: number;
quotes: TrendingSymbol[];
jobTimestamp: number;
startInterval: number;
}
export interface TrendingSymbolsOptions {
lang?: string;
region?: string;
count?: number;
}
const queryOptionsDefaults = {
lang: "en-US",
count: 5,
};
export default function trendingSymbols(
this: ModuleThis,
query: string,
queryOptionsOverrides?: TrendingSymbolsOptions,
moduleOptions?: ModuleOptionsWithValidateTrue,
): Promise<TrendingSymbolsResult>;
export default function trendingSymbols(
this: ModuleThis,
query: string,
queryOptionsOverrides?: TrendingSymbolsOptions,
moduleOptions?: ModuleOptionsWithValidateFalse,
): Promise<any>;
export default function trendingSymbols(
this: ModuleThis,
query: string,
queryOptionsOverrides?: TrendingSymbolsOptions,
moduleOptions?: ModuleOptions,
): Promise<any> {
return this._moduleExec({
moduleName: "trendingSymbols",
query: {
url: "https://${YF_QUERY_HOST}/v1/finance/trending/" + query,
schemaKey: "#/definitions/TrendingSymbolsOptions",
defaults: queryOptionsDefaults,
overrides: queryOptionsOverrides,
},
result: {
schemaKey: "#/definitions/TrendingSymbolsResult",
transformWith(result: any) {
if (!result.finance)
throw new Error("Unexpected result: " + JSON.stringify(result));
return result.finance.result[0];
},
},
moduleOptions,
});
}