Check and apply IB Excel formatting conventions (black=formulas, blue=hardcoded, green=cross-sheet, red=external/provider)
Project description
ib-excel-formatting
A Python package to check and apply Investment Banking Excel formatting conventions. This tool helps maintain financial modeling standards by ensuring cell font colors correctly reflect the nature of their content (hardcoded vs. formula vs. cross-reference).
Overview
In professional financial modeling, specific font colors are used to denote the source of data in a cell:
- Blue: Hardcoded non-string values.
- Black: Formulas referencing the same sheet.
- Green: Formulas referencing other sheets within the same workbook.
- Red: Formulas referencing external workbooks or external data providers (Bloomberg, Capital IQ, FactSet).
ib-excel-formatting automates the verification and application of these conventions using openpyxl.
Installation
The package requires Python 3.10 or higher and depends on openpyxl.
pip install ib-excel-formatting
Usage
The package exports two main functions: check_formatting_conventions and apply_formatting_conventions. By default, both functions process all sheets in the workbook unless a specific sheet or cell range is provided.
Checking Conventions
Use check_formatting_conventions to identify cells that do not follow the IB standard.
from pathlib import Path
from ib_excel_formatting import check_formatting_conventions
file_path = "financial_model.xlsx"
passed, violations = check_formatting_conventions(file_path)
if not passed:
print(f"Found {len(violations)} formatting violations:")
for violation in violations:
print(f" - {violation}")
else:
print("All cells follow IB formatting conventions.")
Applying Conventions
Use apply_formatting_conventions to automatically update the font colors of cells based on their content.
from ib_excel_formatting import apply_formatting_conventions
file_path = "financial_model.xlsx"
output_path = "financial_model_formatted.xlsx"
# Apply formatting to all sheets
changes_count, details = apply_formatting_conventions(
file_path,
output_path=output_path,
)
print(f"Applied {changes_count} formatting changes.")
Targeted Application
You can restrict the check or application to specific sheets or cells:
# Check only specific cells on a specific sheet
passed, violations = check_formatting_conventions(
file_path,
sheet="Income Statement",
cells=["B5:F20", "H5:H20"],
)
Formatting Rules
The package follows these specific detection rules:
| Content Type | Font Color | Details |
|---|---|---|
| Hardcoded | Blue | Non-string values (numbers, booleans, dates). |
| Formula (Local) | Black | Formulas referencing only the current sheet. |
| Formula (Cross-sheet) | Green | Formulas referencing other sheets in the same workbook. |
| External/Data | Red | External workbook references or data provider functions. |
External Data Providers
The following data provider functions are automatically detected and marked as red:
- Bloomberg:
BDP,BDH,BDS - Capital IQ:
CIQ,CIQRANGE - FactSet:
FDS,FDSINFO,FQL
Limitations
- Theme Colors: Excel theme and tint colors are resolved using heuristics. Some custom themes may not be perfectly identified.
- Complex Formulas: Detection of cross-sheet references relies on explicit
Sheet!Cellsyntax. References viaINDIRECTor named ranges may not be correctly identified. - Strings: Hardcoded strings are generally ignored by the formatting logic to avoid affecting labels and headers.
Dependencies
- Python >= 3.10
- openpyxl >= 3.1.5
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ib_excel_formatting-0.1.0.tar.gz.
File metadata
- Download URL: ib_excel_formatting-0.1.0.tar.gz
- Upload date:
- Size: 95.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9f47a568e61fd6bd367619786ec15afb18ff3d71c254805dabd53f004a2ee8d
|
|
| MD5 |
7ff2e9f035ab73826f118f386f56b167
|
|
| BLAKE2b-256 |
49ff6cc191363d02e6d7aacf70903792f9ed2e5f153b3fc0920405f50627e880
|
File details
Details for the file ib_excel_formatting-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ib_excel_formatting-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f74771c483e219d58e0694b1f87c0c5de98858a53df6a3952b11880e698ebbdc
|
|
| MD5 |
e765209752dfabf8f012f5dae214c43e
|
|
| BLAKE2b-256 |
9e4cdd01ea0c0c6156f640594e93d41ed127eb2e95cd7a9d0e5d03c670441910
|