Skip to content

Commit c619154

Browse files
market-status: Support nyse market and finnhub-secondary adapter (#3901)
Co-authored-by: app-token-issuer-data-feeds[bot] <134377064+app-token-issuer-data-feeds[bot]@users.noreply.github.com>
1 parent 99d8ce9 commit c619154

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

.changeset/tidy-toys-happen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/market-status-adapter': minor
3+
---
4+
5+
Add support for nyse market and finnhub-secondary adapter

packages/composites/market-status/src/config/adapters.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const adapterNames = ['NCFX', 'TRADINGHOURS'] as const
1+
export const adapterNames = ['NCFX', 'TRADINGHOURS', 'FINNHUB_SECONDARY'] as const
22

33
export type AdapterName = (typeof adapterNames)[number]
44

@@ -16,4 +16,8 @@ export const marketAdapters: Record<string, { primary: AdapterName; secondary: A
1616
primary: 'NCFX',
1717
secondary: 'TRADINGHOURS',
1818
},
19+
nyse: {
20+
primary: 'TRADINGHOURS',
21+
secondary: 'FINNHUB_SECONDARY',
22+
},
1923
}

packages/composites/market-status/src/config/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ export const config = new AdapterConfig({
1111
type: 'string',
1212
required: true,
1313
},
14+
FINNHUB_SECONDARY_ADAPTER_URL: {
15+
description: 'URL of the Finnhub Secondary adapter',
16+
type: 'string',
17+
required: true,
18+
},
1419
BACKGROUND_EXECUTE_MS: {
1520
description:
1621
'The amount of time the background execute should sleep before performing the next request',

packages/composites/market-status/test/integration/adapter.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('execute', () => {
1616
oldEnv = JSON.parse(JSON.stringify(process.env))
1717
process.env.NCFX_ADAPTER_URL = 'https://ncfx-adapter.com'
1818
process.env.TRADINGHOURS_ADAPTER_URL = 'https://tradinghours-adapter.com'
19+
process.env.FINNHUB_SECONDARY_ADAPTER_URL = 'https://finnhub-secondary-adapter.com'
1920

2021
const adapter = (await import('./../../src')).adapter as unknown as Adapter
2122
clock = FakeTimers.install()
@@ -165,4 +166,18 @@ describe('execute', () => {
165166
},
166167
})
167168
})
169+
170+
describe('for nyse market', () => {
171+
it('returns open if tradinghours is open', async () => {
172+
const market = 'nyse'
173+
fixtures.mockTradinghoursOpen(market)
174+
fixtures.mockFinnhubSecondaryClosed(market)
175+
})
176+
177+
it('returns open if tradinghours is unknown and finnhub is open', async () => {
178+
const market = 'nyse'
179+
fixtures.mockTradinghoursUnknown(market)
180+
fixtures.mockFinnhubSecondaryOpen(market)
181+
})
182+
})
168183
})

packages/composites/market-status/test/integration/fixtures.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,29 @@ export const mockNCFXError = (market: string): nock.Scope => {
7878
.post('/', { data: { endpoint: 'market-status', market } })
7979
.reply(500, {})
8080
}
81+
82+
export const mockFinnhubSecondaryOpen = (market: string): nock.Scope => {
83+
return nock('https://finnhub-secondary-adapter.com')
84+
.persist()
85+
.post('/', { data: { endpoint: 'market-status', market } })
86+
.reply(200, {
87+
result: 2,
88+
statusCode: 200,
89+
data: {
90+
result: 2,
91+
},
92+
})
93+
}
94+
95+
export const mockFinnhubSecondaryClosed = (market: string): nock.Scope => {
96+
return nock('https://finnhub-secondary-adapter.com')
97+
.persist()
98+
.post('/', { data: { endpoint: 'market-status', market } })
99+
.reply(200, {
100+
result: 1,
101+
statusCode: 200,
102+
data: {
103+
result: 1,
104+
},
105+
})
106+
}

0 commit comments

Comments
 (0)