Skip to content

Commit af397de

Browse files
authored
build: Set up CI pipeline
Set up GitHub Action pipeline for testing, building, and publishing the package Closes PR #3
2 parents 0f01ed6 + 1dbda79 commit af397de

File tree

5 files changed

+97
-17
lines changed

5 files changed

+97
-17
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python package
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
release:
12+
types: [published]
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
python-version: ["3.8", "3.9", "3.10"]
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
- name: Install package and dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install build flake8 pytest
32+
pip install -e .
33+
- name: Lint with flake8
34+
run: |
35+
# stop the build if there are Python syntax errors or undefined names
36+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
37+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
38+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
39+
- name: Test with pytest
40+
run: |
41+
pytest
42+
- name: Build package
43+
run: python -m build
44+
- name: Archive production artifacts
45+
uses: actions/upload-artifact@v2
46+
with:
47+
name: dist
48+
path: |
49+
dist/**/*.tar.gz
50+
dist/**/*.whl
51+
52+
deploy:
53+
needs: build
54+
if: github.event_name == 'release' && github.event.action == 'published'
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- uses: actions/checkout@v2
59+
- name: Set up Python
60+
uses: actions/setup-python@v2
61+
with:
62+
python-version: '3.10'
63+
- name: Install dependencies
64+
run: |
65+
python -m pip install --upgrade pip
66+
pip install build twine
67+
68+
- name: Download Python package from build job
69+
uses: actions/download-artifact@v2
70+
with:
71+
name: dist
72+
path: ./dist
73+
74+
- name: Test publishing
75+
env:
76+
TWINE_USERNAME: __token__
77+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
78+
run: |
79+
twine upload -r testpypi dist/*
80+
81+
# twine upload dist/*

.vscode/launch.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
{
8-
"name": "Python (External): Start main.py",
9-
"type": "python",
10-
"request": "launch",
11-
"program": "${workspaceRoot}/main.py",
12-
"console": "externalTerminal"
13-
},
147
{
158
"name": "Python (Integrated): Start main.py",
169
"type": "python",
1710
"request": "launch",
1811
"program": "${workspaceRoot}/main.py",
1912
"console": "integratedTerminal"
20-
}
13+
},
2114
]
2215
}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# README
1+
# smithwilson
22
## Overview
33
This Python package implements the Smith-Wilson yield curve fitting algorithm. It allows for interpolations and extrapolations of zero-coupon bond rates. This algorithm is used for the extrapolation of [EIOPA risk-free term structures](https://eiopa.europa.eu/Publications/Standards/Technical%20Documentation%20(31%20Jan%202018).pdf) in the Solvency II framework. Details are available in the Technical Paper [QIS 5 Risk-free interest rates](https://eiopa.europa.eu/Publications/QIS/ceiops-paper-extrapolation-risk-free-rates_en-20100802.pdf). Examples of extrapolated yield curves including the parameters applied can be found [here](https://eiopa.europa.eu/Publications/Standards/EIOPA_RFR_20190531.zip).
44
<br /><br />
@@ -83,16 +83,16 @@ contain any set of maturities (e.g. more granular maturity structure (interpolat
8383

8484
The Smith-Wilson fitting algorithm calculates first the Wilson-matrix (EIOPA, 2010, p. 16):
8585

86-
`W = e^(-UFR * (t1 + t2)) * (α * min(t1, t2) - 0.5 * e^(-α * max(t1, t2))
87-
* (e^(α * min(t1, t2)) - e^(-α * min(t1, t2))))`
86+
W = e^(-UFR * (t1 + t2)) * (α * min(t1, t2) - 0.5 * e^(-α * max(t1, t2))
87+
* (e^(α * min(t1, t2)) - e^(-α * min(t1, t2))))
8888

8989
Given the Wilson-matrix `W`, vector of UFR discount factors `μ` and prices `P`, the parameter vector `ζ` can be calculated as follows (EIOPA, 2010, p.17):
9090

91-
`ζ = W^-1 * (μ - P)`
91+
ζ = W^-1 * (μ - P)
9292

9393
With the Smith-Wilson parameter `ζ` and Wilson-matrix `W`, the zero-coupon bond prices can be represented as (EIOPA, 2010, p. 18) in matrix notation:
9494

95-
`P = e^(-t * UFR) - W * ζ`
95+
P = e^(-t * UFR) - W * ζ
9696

9797
In the last case, `t` can be any maturity vector, i.e. with additional maturities to extrapolate rates.
9898
<br /><br />

requirements.txt

-68 Bytes
Binary file not shown.

setup.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@
55

66
setuptools.setup(
77
name="smithwilson",
8-
version="0.2.0",
8+
version="0.1.0",
99
author="Dejan Simic",
10-
author_email="dejan.simic",
11-
description="Implementation of the Smith-Wilson yield curve fitting algorithm in Python for interpolations and extrapolations of zero-coupon bond rates",
10+
# author_email="dejan.simic",
11+
description=
12+
"Implementation of the Smith-Wilson yield curve fitting algorithm in Python for interpolations and extrapolations of zero-coupon bond rates",
1213
long_description=long_description,
1314
long_description_content_type="text/markdown",
1415
url="https://github.com/simicd/smith-wilson-py.git",
1516
packages=setuptools.find_packages(),
1617
classifiers=[
17-
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3.7",
19+
"Programming Language :: Python :: 3.8",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
1822
"License :: OSI Approved :: MIT License",
1923
"Operating System :: OS Independent",
2024
],
25+
python_requires='>=3.7',
26+
install_requires=["numpy>=1.21.5"],
2127
)

0 commit comments

Comments
 (0)