laplace-api 1.0.4 → 1.0.8
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
|
@@ -25,6 +25,10 @@ export interface StockStats {
|
|
|
25
25
|
'3YearReturn': number;
|
|
26
26
|
'5YearReturn': number;
|
|
27
27
|
symbol: string;
|
|
28
|
+
latestPrice: number;
|
|
29
|
+
dailyChange: number;
|
|
30
|
+
dayLow: number;
|
|
31
|
+
dayHigh: number;
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
export enum StockStatsKey {
|
|
@@ -32,8 +36,11 @@ export enum StockStatsKey {
|
|
|
32
36
|
MarketCap = 'market_cap',
|
|
33
37
|
FK = 'fk',
|
|
34
38
|
PDDD = 'pddd',
|
|
39
|
+
DayLow = 'day_low',
|
|
40
|
+
DayHigh = 'day_high',
|
|
35
41
|
YearLow = 'year_low',
|
|
36
42
|
YearHigh = 'year_high',
|
|
43
|
+
DailyChange = 'daily_change',
|
|
37
44
|
WeeklyReturn = 'weekly_return',
|
|
38
45
|
MonthlyReturn = 'monthly_return',
|
|
39
46
|
ThreeMonthReturn = '3_month_return',
|
package/src/client/live_price.ts
CHANGED
|
@@ -31,14 +31,12 @@ export interface USStockLiveData {
|
|
|
31
31
|
ap: number; // AskPrice
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export class LivePriceClient {
|
|
35
|
-
constructor(private client: Client) {}
|
|
36
|
-
|
|
34
|
+
export class LivePriceClient extends Client {
|
|
37
35
|
getLivePriceForBIST(symbols: string[], region: Region): AsyncGenerator<BISTStockLiveData, void, undefined> {
|
|
38
|
-
return getLivePrice<BISTStockLiveData>(this
|
|
36
|
+
return getLivePrice<BISTStockLiveData>(this, symbols, region);
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
getLivePriceForUS(symbols: string[], region: Region): AsyncGenerator<USStockLiveData, void, undefined> {
|
|
42
|
-
return getLivePrice<USStockLiveData>(this
|
|
40
|
+
return getLivePrice<USStockLiveData>(this, symbols, region);
|
|
43
41
|
}
|
|
44
42
|
}
|
|
@@ -30,32 +30,48 @@ describe('FinancialFundamentals', () => {
|
|
|
30
30
|
test('GetStockStats', async () => {
|
|
31
31
|
var statKeys = [
|
|
32
32
|
StockStatsKey.PreviousClose,
|
|
33
|
-
StockStatsKey.YtdReturn,
|
|
34
|
-
StockStatsKey.YearlyReturn,
|
|
35
33
|
StockStatsKey.MarketCap,
|
|
36
34
|
StockStatsKey.FK,
|
|
37
35
|
StockStatsKey.PDDD,
|
|
38
36
|
StockStatsKey.YearLow,
|
|
39
37
|
StockStatsKey.YearHigh,
|
|
38
|
+
StockStatsKey.WeeklyReturn,
|
|
39
|
+
StockStatsKey.MonthlyReturn,
|
|
40
|
+
StockStatsKey.ThreeMonthReturn,
|
|
41
|
+
StockStatsKey.YtdReturn,
|
|
42
|
+
StockStatsKey.YearlyReturn,
|
|
40
43
|
StockStatsKey.ThreeYearReturn,
|
|
41
44
|
StockStatsKey.FiveYearReturn,
|
|
42
45
|
StockStatsKey.LatestPrice,
|
|
46
|
+
StockStatsKey.DailyChange,
|
|
47
|
+
StockStatsKey.DayLow,
|
|
48
|
+
StockStatsKey.DayHigh,
|
|
43
49
|
]
|
|
44
50
|
const resp = await stockClient.getStockStats(['TUPRS'], statKeys, Region.Tr);
|
|
45
51
|
expect(resp).not.toBeEmpty();
|
|
46
52
|
expect(resp.length).toBe(1);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
var currentStockStats = resp[0];
|
|
56
|
+
expect(currentStockStats).not.toBeEmpty();
|
|
57
|
+
expect(currentStockStats.symbol).toBe('TUPRS');
|
|
58
|
+
expect(currentStockStats.previousClose).toBeGreaterThan(0.0);
|
|
59
|
+
expect(currentStockStats.marketCap).toBeGreaterThan(0.0);
|
|
60
|
+
expect(currentStockStats.peRatio).not.toBe(0.0);
|
|
61
|
+
expect(currentStockStats.pbRatio).not.toBe(0.0);
|
|
62
|
+
expect(currentStockStats.yearLow).toBeGreaterThan(0.0);
|
|
63
|
+
expect(currentStockStats.yearHigh).toBeGreaterThan(0.0);
|
|
64
|
+
expect(currentStockStats.weeklyReturn).not.toBe(0.0);
|
|
65
|
+
expect(currentStockStats.monthlyReturn).not.toBe(0.0);
|
|
66
|
+
expect(currentStockStats['3MonthReturn']).not.toBe(0.0);
|
|
67
|
+
expect(currentStockStats.ytdReturn).not.toBe(0.0);
|
|
68
|
+
expect(currentStockStats.yearlyReturn).not.toBe(0.0);
|
|
69
|
+
expect(currentStockStats['3YearReturn']).not.toBe(0.0);
|
|
70
|
+
expect(currentStockStats['5YearReturn']).not.toBe(0.0);
|
|
71
|
+
expect(currentStockStats.latestPrice).toBeGreaterThan(0.0);
|
|
72
|
+
expect(currentStockStats.dailyChange).not.toBe(0.0);
|
|
73
|
+
expect(currentStockStats.dayLow).toBeGreaterThan(0.0);
|
|
74
|
+
expect(currentStockStats.dayHigh).toBeGreaterThan(0.0);
|
|
59
75
|
});
|
|
60
76
|
|
|
61
77
|
test('GetTopMovers', async () => {
|
|
@@ -29,6 +29,9 @@ describe('FinancialRatios', () => {
|
|
|
29
29
|
test('GetHistoricalRatios', async () => {
|
|
30
30
|
const resp = await financialClient.getHistoricalRatios('TUPRS', [HistoricalRatiosKey.PriceToEarningsRatio], Region.Tr);
|
|
31
31
|
expect(resp).not.toBeEmpty();
|
|
32
|
+
for (const [_, format] of Object.entries(resp.formatting)) {
|
|
33
|
+
expect(format.name).not.toBeEmpty();
|
|
34
|
+
}
|
|
32
35
|
});
|
|
33
36
|
|
|
34
37
|
test('GetHistoricalRatiosDescriptions', async () => {
|