Operations patterns for FinCal API
How a real operations team wires market calendars into daily automation: guards, early-close slots, caching, cut-offs and tests. Plain-text version for agents: /llms-patterns.txt.
# FinCal API: operations patterns (how a real operations team wires FinCal into daily automation)
# https://fincalapi.com/patterns
Read this after the field meanings in https://fincalapi.com/llms-full.txt. Some calls below use the day-profile and cut-off endpoints;
if one answers 404 it is not enabled on that deployment, and /v1/day_status covers the same ground more simply.
## 1. REST or MCP: which to use
- Scripts, cron jobs and services: REST (/v1/day_profile, /v1/day_status) with a local cache. They run unattended and must
not depend on an agent being present.
- Agents and people asking questions ("is it too late to wire today?"): the MCP tools (setup: https://fincalapi.com/mcp).
- Dashboards and pages: REST, answered once and cached for the day.
- Rule of thumb: MCP for questions, REST for guards.
## 2. Three layers of guard
1. Scheduler: skip full holidays with the scheduler's business-days option. Cheap and declarative, but blind to early
closes and to which calendar a job cares about.
2. In the script: ask FinCal for today's session and exit quietly when the market is closed. One job may care about NYSE
(equities), another about SIFMA-US (bonds).
3. Monitor: a dashboard check that every expected job actually ran in its slot, so a missed run is a red row, not a
silent gap.
## 3. Pick the calendar from what the job touches
Equities and ETFs: NYSE. Bills, notes and repo: SIFMA-US. Wires and settlement: also check the Federal Reserve schedule
(/v1/cutoffs?system=FEDWIRE-FUNDS shows closed on Fed holidays). Never use one calendar for everything. Real divergences
(all from the calendar data):
2026-04-03 Good Friday NYSE: closed
SIFMA-US: early close 12:00 ET, not a settlement day
2026-10-12 Columbus Day NYSE: open 09:30 to 16:00, no settlement
SIFMA-US: closed
2026-11-11 Veterans Day NYSE: open 09:30 to 16:00, no settlement
SIFMA-US: closed
2026-11-27 Day after Thanksgiving NYSE: early close 13:00 ET
SIFMA-US: early close 14:00 ET
2026-12-31 New Year's Eve NYSE: normal day, 16:00 close
SIFMA-US: early close 14:00 ET
## 4. Early-close slot pattern
Do not schedule at a fixed clock time. Run the job on a short interval around the normal close and the early close, then
gate in the script: act only if now is within N minutes of today's close plus an offset, where the close comes from
close_utc on /v1/day_profile (never hard-coded). One schedule is then correct on normal and early-close days.
Python:
from datetime import datetime, timedelta, timezone
def is_slot(close_utc, now=None, offset_minutes=0, window_minutes=5):
"""True while `now` is inside [close + offset, close + offset + window).
close_utc is a market's close_utc from /v1/day_profile, e.g. "2026-11-27T18:00Z"."""
now = now or datetime.now(timezone.utc)
start = datetime.fromisoformat(close_utc.replace("Z", "+00:00")) + timedelta(minutes=offset_minutes)
return start <= now < start + timedelta(minutes=window_minutes)
JavaScript:
function isSlot(closeUtc, now = new Date(), offsetMinutes = 0, windowMinutes = 5) {
const start = new Date(closeUtc).getTime() + offsetMinutes * 60000;
return start <= now.getTime() && now.getTime() < start + windowMinutes * 60000;
}
PowerShell (ASCII only, safe for Windows PowerShell 5):
function Test-Slot {
param([string]$CloseUtc, [datetime]$Now = (Get-Date).ToUniversalTime(), [int]$OffsetMinutes = 0, [int]$WindowMinutes = 5)
$style = [System.Globalization.DateTimeStyles]::AdjustToUniversal
$start = ([datetime]::Parse($CloseUtc, [System.Globalization.CultureInfo]::InvariantCulture, $style)).AddMinutes($OffsetMinutes)
return ($Now -ge $start) -and ($Now -lt $start.AddMinutes($WindowMinutes))
}
Example: a capture five minutes after the NYSE close, called as is_slot(close_utc, offset_minutes=5).
## 5. Prior-day awareness
Data produced "for the previous business day" shifts across a holiday. After a holiday the expected as-of date is
GET /v1/previous_business_day?calendar=...&date=<today>, not yesterday. Compute expected dates from FinCal, not from the
calendar on the wall. On 2026-11-27 the previous NYSE business day is 2026-11-25.
## 6. Fail open or fail closed, and caching
Cache each date's answer on disk the first time FinCal answers, so a later outage cannot change a day's behaviour:
import json, os, urllib.request
def day_profile_cached(date, markets="NYSE,SIFMA-US", key=None, cache_dir=os.path.expanduser("~/.fincal-cache")):
"""First answer for a date is written to disk; later runs (and outages) reuse it, so a day never changes mid-day."""
os.makedirs(cache_dir, exist_ok=True)
path = os.path.join(cache_dir, f"{date}_{markets.replace(',', '-')}.json")
if os.path.exists(path):
with open(path) as f:
return json.load(f)
req = urllib.request.Request(f"https://fincalapi.com/v1/day_profile?date={date}&markets={markets}",
headers={"Authorization": f"Bearer {key or os.environ['FINCAL_API_KEY']}"})
with urllib.request.urlopen(req, timeout=10) as r:
data = json.load(r)
with open(path, "w") as f:
json.dump(data, f)
return data
If FinCal is down and nothing is cached, fall back to a small built-in rule (weekends closed, the early-close days you
know) and log loudly. Monitors and polls should fail open (keep watching). Anything that sends or moves money should fail
closed (do not act on a guess).
## 7. "Not ready" is not "broken"
Many feeds are legitimately empty at the start of the day or after a holiday. Log one line when waiting starts, retry
slowly, and alert only after the real deadline. A loop that logs a stack trace every 30 seconds buries a real fault.
## 8. One situational-awareness line on every dashboard
Show a single line from /v1/day_profile at the top of each dashboard, for example "Fri 11/27: early close everywhere, NYSE
13:00, SIFMA-US 14:00; yesterday was a holiday". Fields to read: day_type, summary (a ready sentence), calendar_mismatch,
and per market status, close_time and close_utc. For yesterday, call /v1/day_status for the previous date. It makes every
other check's expectations explainable.
## 9. Session-aware windows for live feeds
Expect prices and ticks only between open and close, with the close read from FinCal (close_utc), not hard-coded. On an
early-close day a fixed 17:00 produces false alarms for hours. Where a market has no sourced normal-day close (SIFMA-US),
close_time is null with an hours_note: treat it as unknown and use your own documented window, not 16:00.
## 10. Cut-offs in operations
- Flag any job scheduled after the day's cut-off for the system it feeds: GET /v1/cutoffs?system=FEDWIRE-SECURITIES (or
systems=A,B,C for several at once).
- "Minutes left before the last cut-off" for a status line: add remaining=true and read next_event.minutes_from_now, or
as_of=<ISO time> to test a guard at a chosen moment. Each item carries on_prior_calendar_day (Fedwire Funds opens the
evening before).
- status not_covered means nothing is sourced for that system and date: unknown, never open or closed. Times exist for
FEDWIRE-FUNDS, FEDWIRE-SECURITIES and CME-GLOBEX-ES standing; BROKERTEC-US-REPO has normal hours; DTC, NSCC, FICC, FedACH
and CME rates are holiday or notice data only (see /v1/cutoffs/systems).
## 11. Keys, limits and etiquette
- One key per integration, and a separate key for MCP so it can be revoked on its own.
- Fetch the year's holidays once (GET /v1/holidays/range) and cache it instead of calling day_status for every date. A 429
means too many requests per minute for the key: honour the Retry-After header.
- Never commit keys. In a committed .mcp.json use an environment variable:
"headers": { "Authorization": "Bearer ${FINCAL_API_KEY}" } (Claude Code expands ${VAR} in url and headers; set the
variable in your shell or scheduler job environment).
- Check GET /v1/announcements daily (no key needed): data corrections change past answers.
## 12. Test your guards before the calendar does
Calendar bugs surface a few times a year. Keep a fixed list of dates and the behaviour you expect:
2026-11-24 normal weekday
-> run everything on the normal schedule
2026-11-26 full holiday for both markets
-> skip market jobs; poll-only jobs stay quiet
2026-11-27 early close, day after a holiday
-> run close-based jobs at the early close; expect stale first prints
2026-11-28 weekend
-> skip
2026-10-12 calendars disagree (equities open, bonds closed)
-> equity jobs run; bond and USD settlement jobs skip
2026-04-03 calendars disagree the other way (equities closed, bonds half day)
-> bond jobs run to 12:00 ET only
Every endpoint and tool that takes a date accepts any date inside the data horizon, so pass date=<test date> to test (and
as_of=<time> on cut-offs). That is the supported way to test.
## 13. Holiday-season runbook
Before each holiday season: GET /v1/upcoming_exceptions?markets=NYSE,SIFMA-US&days=90 lists the closures and early
closes with names. For each one, write down which of your jobs behave differently. Subscribe so you are told: the updates
RSS feed (https://fincalapi.com/updates.rss), webhooks and email alerts (see /v1/plans). A machine-readable summary an agent can read at
the start of a session: GET /v1/digest?format=json (see /v1/plans for the plan it needs).