/v1/previous_business_day

Finds the closest previous business day.

Description

This endpoint calculates the closest preceding business day for a given date on a specified financial calendar. It intelligently skips over weekends and full-close holidays to provide the last valid trading day before the input date.

Endpoint

GET https://fincalapi.com/v1/previous_business_day

Parameters

Name Type Required Description
date string ✅ Yes Base date in `YYYY-MM-DD` format (e.g., `2025-01-01`).
calendar string ✅ Yes Holiday calendar to use (e.g., `SIFMA-US`, `NYSE`).
format string No (Default: `json`) Response format: `json`, `text`, `plain`, `html`, `csv`.

Usage Examples

🧮 Excel Formula

Find the previous business day for a date in cell `A2` on the `SIFMA-US` calendar:

=WEBSERVICE("https://fincalapi.com/v1/previous_business_day?date="&TEXT(A2,"YYYY-MM-DD")&"&calendar=SIFMA-US")

💻 VBA Macro

Automate finding the previous business day:

Function GetPreviousBusinessDay(targetDate As String, calendarName As String) As String
    Dim http As Object
    Set http = CreateObject("MSXML2.XMLHTTP")
    Dim url As String
    url = "https://fincalapi.com/v1/previous_business_day?date=" & targetDate & "&calendar=" & calendarName
    http.Open "GET", url, False
    http.Send
    GetPreviousBusinessDay = http.responseText
End Function

' Example: MsgBox GetPreviousBusinessDay("2025-01-01", "SIFMA-US")

📊 Google Sheets

Import the previous business day into your Google Sheet:

=IMPORTDATA("https://fincalapi.com/v1/previous_business_day?date=2025-01-01&calendar=SIFMA-US")

🐍 Python

Find the previous business day programmatically:

import requests
import json

base_url = "https://fincalapi.com/v1/previous_business_day"
params = {
    "date": "2025-01-01", # New Year's Day, a holiday
    "calendar": "SIFMA-US"
}

response = requests.get(base_url, params=params)

if response.status_code == 200:
    data = response.json()
    print(json.dumps(data, indent=2))
    # Expected output (assuming Dec 31, 2024 was a business day):
    # {
    #   "input_date": "2025-01-01",
    #   "calendar": "SIFMA-US",
    #   "previous_business_day": "2024-12-31"
    # }
else:
    print(f"Error: {response.status_code} - {response.text}")

🖥️ cURL / Terminal

Get the previous business day from the command line:

curl "https://fincalapi.com/v1/previous_business_day?date=2025-01-06&calendar=NYSE"

🌐 Browser

View the result directly in your browser:

https://fincalapi.com/v1/previous_business_day?date=2025-01-01&calendar=SIFMA-US