Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: ccy-instructions
description: 'Instructions for ccy'
applyTo: '/**'
---


# Ccy Instructions


## Development

* Always run `make lint` after code changes — runs taplo, isort, black, ruff, and mypy
* Never edit `readme.md` directly — it is generated from `docs/index.md` via `make docs`
* To run all tests use `make test` — runs all tests in the `tests/` directory using pytest
* To run a specific test file, use `uv run pytest tests/path/to/test_file.py`


## Documentation

* The documentation for ccy is available at `https://ccy.quantmid.com`
* Documentation is built using [mkdocs](https://www.mkdocs.org/) and stored in the `docs/` directory. The documentation source files are written in markdown format.
* Do not use em dashes (—) in documentation files or docstrings. Use colons, parentheses, or restructure the sentence instead.
29 changes: 15 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ jobs:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
python-version: ["3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: pip install -U pip poetry
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: poetry install --all-extras
run: uv sync --all-extras
- name: Install taplo
uses: uncenter/setup-taplo@v1
- name: run lint
run: make lint
- name: run tests
Expand All @@ -48,16 +50,15 @@ jobs:
- build
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Install all dev dependencies
run: make install-dev
- name: build book
run: make book
- name: publish book
run: make publish-book
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync --all-extras --group book
- name: build docs
run: make docs
- name: publish docs
if: github.ref == 'refs/heads/main'
run: make publish-docs
- name: publish
if: ${{ github.ref == 'refs/heads/main' && github.event.head_commit.message == 'release' }}
run: make publish
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ build
docs/build
htmlcov
dist
site
venv
MANIFEST
.python-version
Expand Down
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@readme.md
@.github/copilot-instructions.md
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2009-2023, Quantmind
Copyright (c) 2009-2026, Quantmind
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
32 changes: 14 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,38 @@ clean: ## Remove python cache files
rm -rf .pytest_cache
rm -rf .coverage

.PHONY: docs
docs: ## Build docs
cd docs && make docs

.PHONY: install-dev
install-dev: ## Install packages for development
@./dev/install

.PHONY: lint
lint: ## Run linters
@poetry run ./dev/lint fix
@uv run ./dev/lint fix

.PHONY: lint-check
lint-check: ## Run linters in check mode
@poetry run ./dev/lint
@uv run ./dev/lint

.PHONY: test
test: ## Test with python 3.8 with coverage
@poetry run pytest -x -v --cov --cov-report xml
@uv run pytest -x -v --cov --cov-report xml

.PHONY: publish
publish: ## Release to pypi
@poetry publish --build -u __token__ -p $(PYPI_TOKEN)
@uv build && uv publish --token $(PYPI_TOKEN)

.PHONY: notebook
notebook: ## Run Jupyter notebook server
@poetry run ./dev/start-jupyter 9095
.PHONY: docs
docs: ## Build mkdocs site
uv run mkdocs build

.PHONY: book
book: ## Build static jupyter {book}
poetry run jupyter-book build docs --all
.PHONY: docs-serve
docs-serve: ## Serve docs locally with live reload
uv run mkdocs serve

.PHONY: publish-book
publish-book: ## Publish the book to github pages
poetry run ghp-import -n -p -f docs/_build/html
.PHONY: publish-docs
publish-docs: ## Publish docs to github pages
uv run mkdocs gh-deploy --force

.PHONY: outdated
outdated: ## Show outdated packages
poetry show -o -a
uv tree --outdated
4 changes: 2 additions & 2 deletions dev/install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

pip install -U pip poetry
poetry install --all-extras --with book
pip install -U uv
uv sync --all-extras --group book
3 changes: 3 additions & 0 deletions dev/lint
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ set -e

BLACK_ARG="--check"
RUFF_ARG=""
TAPLO_ARG="format --check"

if [ "$1" = "fix" ] ; then
BLACK_ARG=""
RUFF_ARG="--fix"
TAPLO_ARG="format"
fi

taplo ${TAPLO_ARG}
echo "run black"
black ccy tests --exclude "fluid_common/protos/v2|fluid_apps/db/migrations" ${BLACK_ARG}
echo "run ruff"
Expand Down
1 change: 1 addition & 0 deletions docs/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ccy.quantmind.com
27 changes: 0 additions & 27 deletions docs/_config.yml

This file was deleted.

7 changes: 0 additions & 7 deletions docs/_toc.yml

This file was deleted.

41 changes: 7 additions & 34 deletions docs/dates.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,26 @@
---
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.14.7
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
---

# Dates & Periods

The module is shipped with a ``date`` module for manipulating time periods and
converting dates between different formats. Th *period* function can be use
to create ``Period`` instanc.::
The module is shipped with a `date` module for manipulating time periods and
converting dates between different formats. The *period* function can be used
to create `Period` instances:

```{code-cell} ipython3
```python
import ccy
p = ccy.period("1m")
p
```

```{code-cell} ipython3
```python
p += "2w"
p
```

```{code-cell} ipython3
```python
p += "3m"
p
```

```{code-cell} ipython3
p -= "1w"
p
```

```{code-cell} ipython3
p -= "1w"
p
```

```{code-cell} ipython3
```python
p -= "1w"
p
```

```{code-cell} ipython3

```
50 changes: 14 additions & 36 deletions docs/intro.md → docs/index.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
---
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.14.7
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
---

# Python CCY

## Getting Started
Expand All @@ -21,7 +8,7 @@ pip install ccy
```
* display currencies

```{code-cell} ipython3
```python
import ccy
import pandas as pd
df = pd.DataFrame(ccy.dump_currency_table())
Expand All @@ -30,78 +17,69 @@ df.head(80)

## Main Usage

```{code-cell} ipython3
```python
import ccy
eur = ccy.currency("aud")
eur.printinfo()
```

a currency object has the following properties:
* *code*: the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) three letters codee.
* *twoletterscode*: two letter crg.
* *code*: the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) three letters code.
* *twoletterscode*: two letter code.
* *default_country*: the default [ISO 3166-1 alpha_2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code for the currency.
* *isonumber*: the ISO 4217 number.
* *name*: the name of the currency.
* *order*: default ordering in currency pairs (more of this below).
* *rounding*: number of decimal places

+++

## Currency Crosses

You can create currency pairs by using the `currency_pair` function:

You can create currency pairs by using the ``currency_pair`` functn::

```{code-cell} ipython3
```python
c = ccy.currency_pair("eurusd")
c
```

```{code-cell} ipython3
```python
c.mkt()
```

```{code-cell} ipython3
```python
c = ccy.currency_pair("chfusd")
c
```

```{code-cell} ipython3
c.mkt() # market convention pair
```

## cross & crossover

Some shortcuts:

```{code-cell} ipython3
```python
ccy.cross("aud")
```

```{code-cell} ipython3
```python
ccy.crossover('eur')
```

```{code-cell} ipython3
```python
ccy.crossover('chf')
```

```{code-cell} ipython3
```python
ccy.crossover('aud')
```

Note, the Swiss franc cross is represented as 'USD/CHF', while the Aussie Dollar and Euro crosses are represented with the USD as denominator. This is the market convention which is handled by the order property of a currency object.

+++

## Eurozone

The euro area, commonly called the eurozone (EZ), is a currency union of 20 member states of the European Union (EU) that have adopted the euro (€) as their primary currency and sole legal tender, and have thus fully implemented EMU policies.

```{code-cell} ipython3
```python
ccy.eurozone
```

```{code-cell} ipython3
```python
ccy.print_eurozone()
```
Loading
Loading