Skip to content

Add static-market-hours EA - #5301

Open
dskloetc wants to merge 2 commits into
mainfrom
kloet/static-market-hours
Open

Add static-market-hours EA#5301
dskloetc wants to merge 2 commits into
mainfrom
kloet/static-market-hours

Conversation

@dskloetc

@dskloetc dskloetc commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

https://smartcontract-it.atlassian.net/browse/OPDATA-8204

Description

For some markets we only have 1 source for market status while we need 2 sources for reliability.
Currently we have some hardcoded logic in the market-status EA to serve as backup.
Now we need to add support for 15 more markets and perhaps even more in the future.
Instead of hardcoding more logic into the market-status EA, this PR adds a new EA which can be configured with any schedule in environment variables.

See this document for why we chose this solution.

The EA supports both MarketStatus and TwentyfourFiveMarketStatus results.

A follow-up PR will add a script to generate such schedules from Tradinghours data that can be downloaded with the necessary API keys.

Changes

  1. yarn new with a custom foreground transport as a separate commit.
  2. Implement logic to return market status for the current time based on a configured schedule.
  3. Add validation to make sure the schedule makes sense.
  4. Add unit tests.
  5. Additional unit tests are added to simulate schedules for "NYSE 24/5" and "NYMEX" which are currently hardcoded in market-status to serve as a proof of concept. These unit tests mirror equivalent unit tests for the market-status EA.

Steps to Test

  1. Create an env file with content:
    NYSE_24_5_SCHEDULE='{"timezone":"America/New_York","lastValidDate":"2027-01-01","weekly":[{"status":"WEEKEND","when":[{"days":["FRIDAY"],"times":[{"start":"20:00:00","end":"24:00:00"}]},{"days":["SATURDAY"],"times":[{"start":"00:00:00","end":"24:00:00"}]},{"days":["SUNDAY"],"times":[{"start":"00:00:00","end":"20:00:00"}]}]},{"status":"PRE_MARKET","when":[{"days":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"times":[{"start":"04:00:00","end":"09:30:00"}]}]},{"status":"REGULAR","when":[{"days":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"times":[{"start":"09:30:00","end":"16:00:00"}]}]},{"status":"POST_MARKET","when":[{"days":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"times":[{"start":"16:00:00","end":"20:00:00"}]}]},{"status":"OVERNIGHT","when":[{"days":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY"],"times":[{"start":"00:00:00","end":"04:00:00"},{"start":"20:00:00","end":"24:00:00"}]},{"days":["FRIDAY"],"times":[{"start":"00:00:00","end":"04:00:00"}]},{"days":["SUNDAY"],"times":[{"start":"20:00:00","end":"24:00:00"}]}]}],"exceptions":[{"status":"WEEKEND","start":"2026-01-18 20:00:00","end":"2026-01-19 20:00:00"},{"status":"WEEKEND","start":"2026-02-15 20:00:00","end":"2026-02-16 20:00:00"},{"status":"WEEKEND","start":"2026-04-02 20:00:00","end":"2026-04-03 20:00:00"},{"status":"WEEKEND","start":"2026-05-24 20:00:00","end":"2026-05-25 20:00:00"},{"status":"WEEKEND","start":"2026-06-18 20:00:00","end":"2026-06-19 20:00:00"},{"status":"WEEKEND","start":"2026-07-02 20:00:00","end":"2026-07-03 20:00:00"},{"status":"WEEKEND","start":"2026-09-06 20:00:00","end":"2026-09-07 20:00:00"},{"status":"WEEKEND","start":"2026-11-25 20:00:00","end":"2026-11-26 20:00:00"},{"status":"POST_MARKET","start":"2026-11-27 13:00:00","end":"2026-11-27 17:00:00"},{"status":"WEEKEND","start":"2026-11-27 17:00:00","end":"2026-11-27 20:00:00"},{"status":"POST_MARKET","start":"2026-12-24 13:00:00","end":"2026-12-24 17:00:00"},{"status":"WEEKEND","start":"2026-12-24 17:00:00","end":"2026-12-25 20:00:00"},{"status":"WEEKEND","start":"2026-12-31 20:00:00","end":"2027-01-01 20:00:00"}]}'
    NYMEX_REGULAR_SCHEDULE='{"timezone":"US/Central","lastValidDate":"2027-01-03","defaultStatus":"OPEN","weekly":[{"status":"CLOSED","when":[{"days":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY"],"times":[{"start":"16:00:00","end":"17:00:00"}]},{"days":["FRIDAY"],"times":[{"start":"16:00:00","end":"24:00:00"}]},{"days":["SATURDAY"],"times":[{"start":"00:00:00","end":"24:00:00"}]},{"days":["SUNDAY"],"times":[{"start":"00:00:00","end":"17:00:00"}]}]}],"exceptions":[{"status":"CLOSED","start":"2026-05-25 13:30:00","end":"2026-05-25 17:00:00"},{"status":"CLOSED","start":"2026-06-19 12:00:00","end":"2026-06-21 17:00:00"},{"status":"CLOSED","start":"2026-07-03 12:00:00","end":"2026-07-05 17:00:00"},{"status":"CLOSED","start":"2026-09-07 13:30:00","end":"2026-09-07 17:00:00"},{"status":"CLOSED","start":"2026-11-26 13:30:00","end":"2026-11-26 17:00:00"},{"status":"CLOSED","start":"2026-11-27 13:45:00","end":"2026-11-29 17:00:00"},{"status":"CLOSED","start":"2026-12-24 12:45:00","end":"2026-12-27 17:00:00"},{"status":"CLOSED","start":"2026-12-31 16:00:00","end":"2027-01-03 17:00:00"}]}'
    
  2. curl --silent -S -X POST http://localhost:8080 -H 'Content-Type: application/json' -d '{
      "data": {
        "endpoint": "market-status",
        "market": "nyse",
        "type": "24/5",
        "weekend": "520-020:America/New_York"
      }
    }'
    
    {
      "data": {
        "result": 2,
        "statusString": "REGULAR"
      },
      "statusCode": 200,
      "result": 2,
      "timestamps": {
        "providerDataRequestedUnixMs": 1787062235163,
        "providerDataReceivedUnixMs": 1787062235163
      }
    }
    
    curl --silent -S -X POST http://localhost:8080 -H 'Content-Type: application/json' -d '{
      "data": {
        "endpoint": "market-status",
        "market": "nymex",
        "type": "regular"
      }
    }'
    
    {
      "data": {
        "result": 2,
        "statusString": "OPEN"
      },
      "statusCode": 200,
      "result": 2,
      "timestamps": {
        "providerDataRequestedUnixMs": 1787062254019,
        "providerDataReceivedUnixMs": 1787062254019
      }
    }
    

Quality Assurance

  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant infra-k8s configuration file.
  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant adapter-secrets configuration file.
  • If a new adapter was made, or a new endpoint was added, update the test-payload.json file with relevant requests.
  • The branch naming follows git flow (feature/x, chore/x, release/x, hotfix/x, fix/x) or is created from Jira.
  • This is related to a maximum of one Jira story or GitHub issue.
  • Types are safe (avoid TypeScript/TSLint features like any and disable, instead use more specific types).
  • All code changes have 100% unit and integration test coverage. If testing is not applicable or too difficult to justify doing, the reasoning should be documented explicitly in the PR.

@changeset-bot

changeset-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 783c8ea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@chainlink/static-market-hours-adapter Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dskloetc
dskloetc force-pushed the kloet/static-market-hours branch 5 times, most recently from 38a8dea to 395c71a Compare August 18, 2026 12:55
@dskloetc
dskloetc force-pushed the kloet/static-market-hours branch from 395c71a to 783c8ea Compare August 18, 2026 14:00
@dskloetc
dskloetc marked this pull request as ready for review August 18, 2026 14:14
@dskloetc
dskloetc requested a review from a team August 18, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant