laplace-api 2.0.3 → 2.1.0

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,6 +1,6 @@
1
1
  {
2
2
  "name": "laplace-api",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "description": "Client library for Laplace API for the US stock market and BIST (Istanbul stock market) fundamental financial data.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -91,12 +91,13 @@ export class FinancialFundamentalsClient extends Client {
91
91
  });
92
92
  }
93
93
 
94
- async getTopMovers(region: Region, page: number, pageSize: number, direction: TopMoverDirection): Promise<TopMover[]> {
94
+ async getTopMovers(region: Region, page: number, pageSize: number, direction: TopMoverDirection, assetType?: AssetType): Promise<TopMover[]> {
95
95
  const url = new URL(`${this['baseUrl']}/api/v2/stock/top-movers`);
96
96
  url.searchParams.append('region', region);
97
97
  url.searchParams.append('page', page.toString());
98
98
  url.searchParams.append('pageSize', pageSize.toString());
99
99
  url.searchParams.append('direction', direction);
100
+ if (assetType) url.searchParams.append('assetType', assetType);
100
101
 
101
102
  return this.sendRequest<TopMover[]>({
102
103
  method: 'GET',
@@ -4,6 +4,7 @@ import { Client } from '../client/client';
4
4
  import { FinancialFundamentalsClient, TopMoverDirection } from '../client/financial_fundamentals';
5
5
  import { Region } from '../client/collections';
6
6
  import './client_test_suite';
7
+ import { AssetType } from '../client/stocks';
7
8
 
8
9
  describe('FinancialFundamentals', () => {
9
10
  let client: Client;
@@ -64,7 +65,7 @@ describe('FinancialFundamentals', () => {
64
65
  const pageSize = 20;
65
66
 
66
67
  async function testTopMovers(direction: TopMoverDirection, shouldBePositive: boolean) {
67
- const result = await stockClient.getTopMovers(region, page, pageSize, direction);
68
+ const result = await stockClient.getTopMovers(region, page, pageSize, direction, AssetType.Stock);
68
69
 
69
70
  expect(Array.isArray(result)).toBe(true);
70
71
  expect(result.length).toBeGreaterThan(0);
@@ -80,6 +81,10 @@ describe('FinancialFundamentals', () => {
80
81
  shouldBePositive ? mover.change > 0 : mover.change < 0
81
82
  );
82
83
  expect(directionCheck).toBe(true);
84
+
85
+ const assetTypeCheck = result.every(mover => mover.assetType === AssetType.Stock)
86
+
87
+ expect(assetTypeCheck).toBe(true);
83
88
 
84
89
  expect(result.length).toBeLessThanOrEqual(pageSize);
85
90
  }