laplace-api 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client/live_price.ts +26 -15
package/package.json
CHANGED
package/src/client/live_price.ts
CHANGED
|
@@ -2,21 +2,18 @@ import { Client } from './client';
|
|
|
2
2
|
import { Region } from './collections';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
function getLivePrice<T>(
|
|
6
6
|
client: Client,
|
|
7
7
|
symbols: string[],
|
|
8
|
-
region: Region
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
region: Region,
|
|
9
|
+
streamId: string = uuidv4(),
|
|
10
|
+
): {
|
|
11
|
+
events: AsyncIterable<T>,
|
|
12
|
+
cancel: () => void
|
|
13
|
+
} {
|
|
11
14
|
const url = `${client["baseUrl"]}/api/v1/stock/price/live?filter=${symbols.join(',')}®ion=${region}&stream=${streamId}`;
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
yield* events;
|
|
17
|
-
} finally {
|
|
18
|
-
cancel();
|
|
19
|
-
}
|
|
16
|
+
return client.sendSSERequest<T>(url);
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
export interface BISTStockLiveData {
|
|
@@ -32,11 +29,25 @@ export interface USStockLiveData {
|
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
export class LivePriceClient extends Client {
|
|
35
|
-
getLivePriceForBIST(
|
|
36
|
-
|
|
32
|
+
getLivePriceForBIST(
|
|
33
|
+
symbols: string[],
|
|
34
|
+
region: Region,
|
|
35
|
+
streamId?: string,
|
|
36
|
+
): {
|
|
37
|
+
events: AsyncIterable<BISTStockLiveData>,
|
|
38
|
+
cancel: () => void
|
|
39
|
+
} {
|
|
40
|
+
return getLivePrice<BISTStockLiveData>(this, symbols, region, streamId);
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
getLivePriceForUS(
|
|
40
|
-
|
|
43
|
+
getLivePriceForUS(
|
|
44
|
+
symbols: string[],
|
|
45
|
+
region: Region,
|
|
46
|
+
streamId?: string,
|
|
47
|
+
): {
|
|
48
|
+
events: AsyncIterable<USStockLiveData>,
|
|
49
|
+
cancel: () => void
|
|
50
|
+
} {
|
|
51
|
+
return getLivePrice<USStockLiveData>(this, symbols, region, streamId);
|
|
41
52
|
}
|
|
42
53
|
}
|