Metadata-Version: 2.5
Name: langchain-numbers-sg
Version: 0.1.1
Summary: LangChain tools for Singapore rates, prices and money rules from Numbers.sg: SORA, T-bills, Savings Bonds, COE, CPF, income tax, stamp duty and SGD exchange rates, each with its official source and when it was last read. No API key.
Project-URL: Homepage, https://numbers.sg/developers/langchain/
Project-URL: Documentation, https://numbers.sg/developers/
Project-URL: Source, https://github.com/numbers-sg/langchain-numbers-sg
Project-URL: Issues, https://github.com/numbers-sg/langchain-numbers-sg/issues
Project-URL: Licence, https://numbers.sg/data/licence/
Author: Numbers.sg (Jeremiah Say)
License-Expression: MIT
License-File: LICENSE
Keywords: agent tools,coe,cpf,exchange rates,income tax,langchain,langchain-integration,open data,singapore,sora,stamp duty,t-bills
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.10
Requires-Dist: langchain-core>=0.3.0
Provides-Extra: test
Requires-Dist: langchain-tests>=0.3; extra == 'test'
Requires-Dist: pytest-asyncio>=0.23; extra == 'test'
Requires-Dist: pytest>=7; extra == 'test'
Description-Content-Type: text/markdown

# langchain-numbers-sg

LangChain tools for Singapore's money numbers: SORA, T-bill auctions, Singapore Savings Bonds, COE results, CPF rates and retirement sums, income tax, ABSD and BSD, inflation, the SP electricity tariff and SGD exchange rates, plus five calculators (stamp duty, take-home pay, income tax, CPF contributions, Savings Bond returns).

Every answer says **where the figure came from** (MAS, LTA, CPF Board, IRAS, SingStat, SP Group), **the date of the row**, **when [Numbers.sg](https://numbers.sg/) last read the source**, and **whether that read is late**. It also gives the page to link and a CC BY 4.0 credit line. Free, **no API key**.

**Full guide with worked examples:** https://numbers.sg/developers/langchain/

[![CI](https://github.com/numbers-sg/langchain-numbers-sg/actions/workflows/ci.yml/badge.svg)](https://github.com/numbers-sg/langchain-numbers-sg/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/langchain-numbers-sg)](https://pypi.org/project/langchain-numbers-sg/)

## Install

```bash
pip install -U langchain-numbers-sg
```

## Use it without a model

```python
from langchain_numbers_sg import NumbersSGGetValue

print(NumbersSGGetValue().invoke({
    "id": "coe-results", "field": "quota_premium_sgd", "where": {"category": "A"},
}))
```

What it printed on 4 Dec 2026 (the figures follow LTA’s latest round):

```text
COE bidding results, every round since 2010: quota_premium_sgd = S$130,100, as of 2026-11.
Meaning: The quota premium: what every successful bidder in the category pays.
Row: {"month":"2026-11","round":2,"closing_date":"2026-11-18","category":"A",...}
Source last read: 2026-12-04T08:50:00+08:00 (Singapore time).
Published by: Land Transport Authority (LTA), via data.gov.sg; Department of Statistics (SingStat)
Link: https://numbers.sg/cars/coe-results/
Credit: Source: Land Transport Authority, via data.gov.sg and Department of Statistics, compiled by Numbers.sg (numbers.sg/cars/coe-results/), CC BY 4.0
```

## Use it in an agent

```python
from langchain.agents import create_agent
from langchain_numbers_sg import NumbersSGToolkit

agent = create_agent(
    "anthropic:claude-sonnet-5-5",
    tools=NumbersSGToolkit().get_tools(),
    system_prompt="Answer Singapore money questions with the tools. Give each figure's date and source, and link the page.",
)
agent.invoke({"messages": [{"role": "user", "content":
    "I earn S$6,000 a month and I'm 30. What reaches my bank, and how does that compare with the latest 6-month T-bill yield on a year's savings?"}]})
```

Any chat model that supports tool calling works. Python 3.10 or later; `create_agent` needs LangChain 1.0+.

## The tools

| Tool | What it answers |
|---|---|
| `NumbersSGListDatasets` | Which dataset answers a question, and its id |
| `NumbersSGGetValue` | One figure, ready to quote, with date, source and link |
| `NumbersSGGetDataset` | Rows for trends and comparisons (up to 500; a link to all) |
| `NumbersSGStampDuty` | BSD and ABSD on a Singapore property, tier by tier |
| `NumbersSGTakeHomePay` | Salary after CPF and tax, or the salary for a take-home figure |
| `NumbersSGIncomeTax` | Resident income tax with every relief |
| `NumbersSGCPFContribution` | CPF on a month's pay, with the account split |
| `NumbersSGSSBReturns` | Every interest payment on a Savings Bond, or a switch compared |
| `NumbersSGToolkit` | All eight |

The calculators run the same engines as the calculators on numbers.sg, which are checked against CPF Board's and IRAS's own worked examples. Each answer lists the rules it used, when they were last checked and their official sources.

## Good to know

- **Errors come back as sentences**, not exceptions, so the model can recover (for example, "No dataset …: list_datasets gives every id").
- **Freshness is part of every answer.** `LATE` means a scheduled read of the source did not happen, so a newer figure may exist.
- **Reuse:** data marked `open` is CC BY 4.0, free to republish with the credit line. `facts-only` series can be quoted; check the publisher's terms before republishing a whole series. See https://numbers.sg/data/licence/.
- **One endpoint:** the tools call `https://numbers.sg/api/mcp`, the server listed in the official MCP registry as `io.github.numbers-sg/data`, so the LangChain tools and the MCP server always agree. Set `NUMBERS_SG_ENDPOINT` to point them elsewhere.
- **Not financial advice.** General information from official sources.

## Also from Numbers.sg

- REST API (JSON and CSV, no key): https://numbers.sg/developers/
- Open datasets: [GitHub](https://github.com/numbers-sg/data) · [Hugging Face](https://huggingface.co/numbers-sg) · [Kaggle](https://www.kaggle.com/greencalculus/datasets) · [Zenodo DOI](https://doi.org/10.5281/zenodo.24576628)

## Maintainer

Jeremiah Say ([ORCID 0009-0009-2025-7691](https://orcid.org/0009-0009-2025-7691)), who runs Numbers.sg. Issues and pull requests welcome. MIT licence.
