laplace-api 1.4.3 → 1.4.5
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
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Client } from './client';
|
|
2
2
|
import { Region } from './collections';
|
|
3
|
+
import { AssetClass, AssetType } from './stocks';
|
|
3
4
|
|
|
4
5
|
export interface StockDividend {
|
|
5
6
|
date: Date;
|
|
@@ -55,7 +56,9 @@ export enum StockStatsKey {
|
|
|
55
56
|
|
|
56
57
|
export interface TopMover {
|
|
57
58
|
symbol: string;
|
|
58
|
-
|
|
59
|
+
change: number;
|
|
60
|
+
assetClass: AssetClass;
|
|
61
|
+
assetType: AssetType
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
export enum TopMoverDirection {
|
package/src/client/live-price.ts
CHANGED
|
@@ -44,7 +44,6 @@ export class LivePriceClient extends Client {
|
|
|
44
44
|
feeds: LivePriceFeed[]
|
|
45
45
|
): Promise<string> {
|
|
46
46
|
const url = new URL(`${this["baseUrl"]}/api/v2/ws/url`);
|
|
47
|
-
url.searchParams.append("region", Region.Tr);
|
|
48
47
|
|
|
49
48
|
const params: WebSocketUrlParams = {
|
|
50
49
|
externalUserId,
|
|
@@ -56,8 +56,38 @@ describe('FinancialFundamentals', () => {
|
|
|
56
56
|
expect(currentStockStats.lowerPriceLimit).toBeGreaterThan(0.0)
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
59
|
+
describe('GetTopMovers', () => {
|
|
60
|
+
const region = Region.Tr;
|
|
61
|
+
const page = 0;
|
|
62
|
+
const pageSize = 20;
|
|
63
|
+
|
|
64
|
+
async function testTopMovers(direction: TopMoverDirection, shouldBePositive: boolean) {
|
|
65
|
+
const result = await stockClient.getTopMovers(region, page, pageSize, direction);
|
|
66
|
+
|
|
67
|
+
expect(Array.isArray(result)).toBe(true);
|
|
68
|
+
expect(result.length).toBeGreaterThan(0);
|
|
69
|
+
|
|
70
|
+
result.forEach(mover => {
|
|
71
|
+
expect(mover).toHaveProperty('symbol');
|
|
72
|
+
expect(mover).toHaveProperty('change');
|
|
73
|
+
expect(typeof mover.symbol).toBe('string');
|
|
74
|
+
expect(typeof mover.change).toBe('number');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const directionCheck = result.every(mover =>
|
|
78
|
+
shouldBePositive ? mover.change > 0 : mover.change < 0
|
|
79
|
+
);
|
|
80
|
+
expect(directionCheck).toBe(true);
|
|
81
|
+
|
|
82
|
+
expect(result.length).toBeLessThanOrEqual(pageSize);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
test('should return gainers data', async () => {
|
|
86
|
+
await testTopMovers(TopMoverDirection.Gainers, true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('should return losers data', async () => {
|
|
90
|
+
await testTopMovers(TopMoverDirection.Losers, false);
|
|
91
|
+
});
|
|
62
92
|
});
|
|
63
93
|
});
|
|
@@ -82,37 +82,36 @@ describe("LivePrice", () => {
|
|
|
82
82
|
);
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// });
|
|
85
|
+
describe("US Live Price Tests", () => {
|
|
86
|
+
const symbols = ["AAPL"];
|
|
87
|
+
|
|
88
|
+
it(
|
|
89
|
+
"should receive data for initial and updated symbols for us",
|
|
90
|
+
async () => {
|
|
91
|
+
const receivedData: USStockLiveData[] = [];
|
|
92
|
+
|
|
93
|
+
let unsubscribe: (() => void) | null =
|
|
94
|
+
ws.subscribe<LivePriceFeed.LiveUs>(
|
|
95
|
+
symbols,
|
|
96
|
+
LivePriceFeed.LiveUs,
|
|
97
|
+
(data) => {
|
|
98
|
+
console.log("RECEIVED DATA FOR US", data);
|
|
99
|
+
receivedData.push(data);
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
await new Promise((resolve) => setTimeout(resolve, 20000));
|
|
104
|
+
|
|
105
|
+
for (const symbol of symbols) {
|
|
106
|
+
const symbolData = receivedData.filter(
|
|
107
|
+
(data) => data.symbol === symbol
|
|
108
|
+
);
|
|
109
|
+
expect(symbolData.length).toBeGreaterThan(0);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
unsubscribe();
|
|
113
|
+
},
|
|
114
|
+
TEST_CONSTANTS.JEST_TIMEOUT
|
|
115
|
+
);
|
|
116
|
+
});
|
|
118
117
|
});
|