Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

# [1.6.0-rc.1](https://github.com/fugle-dev/fugle-marketdata-node/compare/v1.5.0...v1.6.0-rc.1) (2026-08-20)


### Features

* add stock ownership institutionalTrades, directorHoldings & tdccDistribution REST endpoints ([7366d0d](https://github.com/fugle-dev/fugle-marketdata-node/commit/7366d0d71ea09d52f5a7dcc7693b1a1b4483aa3a))

# [1.5.0](https://github.com/fugle-dev/fugle-marketdata-node/compare/v1.4.2...v1.5.0) (2026-08-14)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fugle/marketdata",
"version": "1.5.0",
"version": "1.6.0-rc.1",
"description": "Fugle MarketData API client library for Node.js",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
6 changes: 6 additions & 0 deletions src/rest/stock/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import { RestStockCorporateActionsCapitalChangesParams, capitalChanges } from '.
import { RestStockCorporateActionsDividendsParams, dividends } from './corporate-actions/dividends';
import { RestStockCorporateActionsListingApplicantsParams, listingApplicants } from './corporate-actions/listing-applicants';
import { RestStockOwnershipEtfHoldingsParams, etfHoldings } from './ownership/etf-holdings';
import { RestStockOwnershipInstitutionalTradesParams, institutionalTrades } from './ownership/institutional-trades';
import { RestStockOwnershipDirectorHoldingsParams, directorHoldings } from './ownership/director-holdings';
import { RestStockOwnershipTdccDistributionParams, tdccDistribution } from './ownership/tdcc-distribution';

export class RestStockClient extends RestClient {
get intraday() {
Expand Down Expand Up @@ -74,6 +77,9 @@ export class RestStockClient extends RestClient {
const request = this.request;
return {
etfHoldings: (params: RestStockOwnershipEtfHoldingsParams) => etfHoldings(request, params),
institutionalTrades: (params: RestStockOwnershipInstitutionalTradesParams) => institutionalTrades(request, params),
directorHoldings: (params: RestStockOwnershipDirectorHoldingsParams) => directorHoldings(request, params),
tdccDistribution: (params: RestStockOwnershipTdccDistributionParams) => tdccDistribution(request, params),
};
}
}
38 changes: 38 additions & 0 deletions src/rest/stock/ownership/director-holdings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { RestClientRequest } from '../../client';

export interface RestStockOwnershipDirectorHoldingsParams {
symbol: string;
from?: string;
to?: string;
sort?: 'asc' | 'desc';
}

export interface RestStockOwnershipDirectorHoldingsDirector {
order: number;
title: string;
name: string;
electedShares: number;
heldShares: number;
pledgedShares: number;
pledgeRatio: number;
relatedHeldShares: number;
relatedPledgedShares: number;
relatedPledgeRatio: number;
}

export interface RestStockOwnershipDirectorHoldingsResponse {
type?: string;
exchange?: string;
market?: string;
symbol: string;
data: Array<{
/** yyyy-MM (monthly) */
date: string;
directors: RestStockOwnershipDirectorHoldingsDirector[];
}>;
}

export const directorHoldings = (request: RestClientRequest, params: RestStockOwnershipDirectorHoldingsParams) => {
const { symbol, ...options } = params;
return request(`ownership/director-holdings/${symbol}`, options) as Promise<RestStockOwnershipDirectorHoldingsResponse>;
}
33 changes: 33 additions & 0 deletions src/rest/stock/ownership/institutional-trades.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { RestClientRequest } from '../../client';

export interface RestStockOwnershipInstitutionalTradesParams {
symbol: string;
from?: string;
to?: string;
sort?: 'asc' | 'desc';
}

export interface RestStockOwnershipInstitutionalTradesInvestor {
buy: number;
sell: number;
net: number;
}

export interface RestStockOwnershipInstitutionalTradesResponse {
type?: string;
exchange?: string;
market?: string;
symbol: string;
data: Array<{
date: string;
foreign: RestStockOwnershipInstitutionalTradesInvestor;
trust: RestStockOwnershipInstitutionalTradesInvestor;
dealer: RestStockOwnershipInstitutionalTradesInvestor;
total: number;
}>;
}

export const institutionalTrades = (request: RestClientRequest, params: RestStockOwnershipInstitutionalTradesParams) => {
const { symbol, ...options } = params;
return request(`ownership/institutional-trades/${symbol}`, options) as Promise<RestStockOwnershipInstitutionalTradesResponse>;
}
31 changes: 31 additions & 0 deletions src/rest/stock/ownership/tdcc-distribution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { RestClientRequest } from '../../client';

export interface RestStockOwnershipTdccDistributionParams {
symbol: string;
from?: string;
to?: string;
sort?: 'asc' | 'desc';
}

export interface RestStockOwnershipTdccDistributionLevel {
range: string;
holders: number;
shares: number;
proportion: number;
}

export interface RestStockOwnershipTdccDistributionResponse {
type?: string;
exchange?: string;
market?: string;
symbol: string;
data: Array<{
date: string;
distributions: RestStockOwnershipTdccDistributionLevel[];
}>;
}

export const tdccDistribution = (request: RestClientRequest, params: RestStockOwnershipTdccDistributionParams) => {
const { symbol, ...options } = params;
return request(`ownership/tdcc-distribution/${symbol}`, options) as Promise<RestStockOwnershipTdccDistributionResponse>;
}
99 changes: 99 additions & 0 deletions test/rest-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ describe('RestClient', () => {
const stock = client.stock as RestStockClient;
expect(stock.ownership).toBeDefined();
expect(stock.ownership).toHaveProperty('etfHoldings');
expect(stock.ownership).toHaveProperty('institutionalTrades');
expect(stock.ownership).toHaveProperty('directorHoldings');
expect(stock.ownership).toHaveProperty('tdccDistribution');
});

describe('.etfHoldings()', () => {
Expand Down Expand Up @@ -345,6 +348,102 @@ describe('RestClient', () => {
);
});
});

describe('.institutionalTrades()', () => {
it('should request with api key', async () => {
const client = new RestClient({ apiKey: 'api-key' });
const stock = client.stock as RestStockClient;
await stock.ownership.institutionalTrades({ symbol: '2330' });
expect(fetch).toBeCalledWith(
'https://api.fugle.tw/marketdata/v1.0/stock/ownership/institutional-trades/2330',
{ headers: { 'X-API-KEY': 'api-key' } },
);
});

it('should request with bearer token', async () => {
const client = new RestClient({ bearerToken: 'bearer-token' });
const stock = client.stock as RestStockClient;
await stock.ownership.institutionalTrades({ symbol: '2330' });
expect(fetch).toBeCalledWith(
'https://api.fugle.tw/marketdata/v1.0/stock/ownership/institutional-trades/2330',
{ headers: { 'Authorization': 'Bearer bearer-token' } },
);
});

it('should request with query params', async () => {
const client = new RestClient({ apiKey: 'api-key' });
const stock = client.stock as RestStockClient;
await stock.ownership.institutionalTrades({ symbol: '2330', from: '2026-07-01', to: '2026-07-31', sort: 'desc' });
expect(fetch).toBeCalledWith(
'https://api.fugle.tw/marketdata/v1.0/stock/ownership/institutional-trades/2330?from=2026-07-01&sort=desc&to=2026-07-31',
{ headers: { 'X-API-KEY': 'api-key' } },
);
});
});

describe('.directorHoldings()', () => {
it('should request with api key', async () => {
const client = new RestClient({ apiKey: 'api-key' });
const stock = client.stock as RestStockClient;
await stock.ownership.directorHoldings({ symbol: '2330' });
expect(fetch).toBeCalledWith(
'https://api.fugle.tw/marketdata/v1.0/stock/ownership/director-holdings/2330',
{ headers: { 'X-API-KEY': 'api-key' } },
);
});

it('should request with bearer token', async () => {
const client = new RestClient({ bearerToken: 'bearer-token' });
const stock = client.stock as RestStockClient;
await stock.ownership.directorHoldings({ symbol: '2330' });
expect(fetch).toBeCalledWith(
'https://api.fugle.tw/marketdata/v1.0/stock/ownership/director-holdings/2330',
{ headers: { 'Authorization': 'Bearer bearer-token' } },
);
});

it('should request with query params', async () => {
const client = new RestClient({ apiKey: 'api-key' });
const stock = client.stock as RestStockClient;
await stock.ownership.directorHoldings({ symbol: '2330', from: '2026-01-01', to: '2026-05-31', sort: 'desc' });
expect(fetch).toBeCalledWith(
'https://api.fugle.tw/marketdata/v1.0/stock/ownership/director-holdings/2330?from=2026-01-01&sort=desc&to=2026-05-31',
{ headers: { 'X-API-KEY': 'api-key' } },
);
});
});

describe('.tdccDistribution()', () => {
it('should request with api key', async () => {
const client = new RestClient({ apiKey: 'api-key' });
const stock = client.stock as RestStockClient;
await stock.ownership.tdccDistribution({ symbol: '2330' });
expect(fetch).toBeCalledWith(
'https://api.fugle.tw/marketdata/v1.0/stock/ownership/tdcc-distribution/2330',
{ headers: { 'X-API-KEY': 'api-key' } },
);
});

it('should request with bearer token', async () => {
const client = new RestClient({ bearerToken: 'bearer-token' });
const stock = client.stock as RestStockClient;
await stock.ownership.tdccDistribution({ symbol: '2330' });
expect(fetch).toBeCalledWith(
'https://api.fugle.tw/marketdata/v1.0/stock/ownership/tdcc-distribution/2330',
{ headers: { 'Authorization': 'Bearer bearer-token' } },
);
});

it('should request with query params', async () => {
const client = new RestClient({ apiKey: 'api-key' });
const stock = client.stock as RestStockClient;
await stock.ownership.tdccDistribution({ symbol: '2330', from: '2026-06-01', to: '2026-07-03', sort: 'desc' });
expect(fetch).toBeCalledWith(
'https://api.fugle.tw/marketdata/v1.0/stock/ownership/tdcc-distribution/2330?from=2026-06-01&sort=desc&to=2026-07-03',
{ headers: { 'X-API-KEY': 'api-key' } },
);
});
});
});

describe('.snapshot', () => {
Expand Down
Loading