qablet-contracts 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ FROM python:3.7-slim
2
+ COPY . /app
3
+ WORKDIR /app
4
+ RUN pip install .
5
+ CMD ["qablet_contracts"]
@@ -0,0 +1,6 @@
1
+ Changelog
2
+ =========
3
+
4
+ 0.1.0 (2021-08-14)
5
+ ------------------
6
+ - A place holder.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 qablet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ include LICENSE
2
+ include HISTORY.md
3
+ include Containerfile
4
+ graft tests
5
+ graft qablet_contracts
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.1
2
+ Name: qablet_contracts
3
+ Version: 0.1.0
4
+ Summary: Awesome qablet_contracts created by qablet
5
+ Home-page: https://github.com/qablet/qablet-contracts/
6
+ Author: qablet
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: pyarrow
10
+ Requires-Dist: pandas
11
+ Requires-Dist: numpy
12
+ Provides-Extra: test
13
+ Requires-Dist: pytest; extra == "test"
14
+ Requires-Dist: coverage; extra == "test"
15
+ Requires-Dist: flake8; extra == "test"
16
+ Requires-Dist: black; extra == "test"
17
+ Requires-Dist: isort; extra == "test"
18
+ Requires-Dist: pytest-cov; extra == "test"
19
+ Requires-Dist: mypy; extra == "test"
20
+ Requires-Dist: gitchangelog; extra == "test"
21
+ Requires-Dist: mkdocs; extra == "test"
22
+ Requires-Dist: mkdocstrings; extra == "test"
23
+ Requires-Dist: pyarrow; extra == "test"
24
+ Requires-Dist: pandas; extra == "test"
25
+ Requires-Dist: numpy; extra == "test"
26
+ Requires-Dist: ruff; extra == "test"
27
+
28
+ # qablet_contracts
29
+
30
+ This is a work in progress.
31
+
32
+ [![codecov](https://codecov.io/gh/qablet/qablet-contracts/branch/main/graph/badge.svg?token=qablet-contracts_token_here)](https://codecov.io/gh/qablet/qablet-contracts)
33
+ [![CI](https://github.com/qablet/qablet-contracts/actions/workflows/main.yml/badge.svg)](https://github.com/qablet/qablet-contracts/actions/workflows/main.yml)
34
+
35
+ Awesome qablet_contracts created by qablet
36
+
37
+ ## Install it from PyPI
38
+
39
+ ```bash
40
+ pip install qablet_contracts
41
+ ```
42
+
43
+ ## What is qablet
44
+ TBD
45
+
46
+ ## How to use qablet-contracts
47
+ TBD
48
+
49
+ ## What is in this repo?
50
+ TBD
51
+
52
+ ## Provide feedback
53
+
54
+ ## Usage
55
+
56
+ ```py
57
+ from qablet_contracts import BaseClass
58
+ from qablet_contracts import base_function
59
+
60
+ BaseClass().base_method()
61
+ base_function()
62
+ ```
63
+
64
+ ```bash
65
+ $ python -m qablet_contracts
66
+ #or
67
+ $ qablet_contracts
68
+ ```
69
+
70
+ ## Development
71
+
72
+ TBD.
@@ -0,0 +1,45 @@
1
+ # qablet_contracts
2
+
3
+ This is a work in progress.
4
+
5
+ [![codecov](https://codecov.io/gh/qablet/qablet-contracts/branch/main/graph/badge.svg?token=qablet-contracts_token_here)](https://codecov.io/gh/qablet/qablet-contracts)
6
+ [![CI](https://github.com/qablet/qablet-contracts/actions/workflows/main.yml/badge.svg)](https://github.com/qablet/qablet-contracts/actions/workflows/main.yml)
7
+
8
+ Awesome qablet_contracts created by qablet
9
+
10
+ ## Install it from PyPI
11
+
12
+ ```bash
13
+ pip install qablet_contracts
14
+ ```
15
+
16
+ ## What is qablet
17
+ TBD
18
+
19
+ ## How to use qablet-contracts
20
+ TBD
21
+
22
+ ## What is in this repo?
23
+ TBD
24
+
25
+ ## Provide feedback
26
+
27
+ ## Usage
28
+
29
+ ```py
30
+ from qablet_contracts import BaseClass
31
+ from qablet_contracts import base_function
32
+
33
+ BaseClass().base_method()
34
+ base_function()
35
+ ```
36
+
37
+ ```bash
38
+ $ python -m qablet_contracts
39
+ #or
40
+ $ qablet_contracts
41
+ ```
42
+
43
+ ## Development
44
+
45
+ TBD.
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ 0.1.0
File without changes
@@ -0,0 +1,17 @@
1
+ """
2
+ qablet_contracts base module.
3
+
4
+ This is the principal module of the qablet_contracts project.
5
+ here you put your main classes and objects.
6
+
7
+ Be creative! do whatever you want!
8
+
9
+ If you want to replace this with a Flask application run:
10
+
11
+ $ make init
12
+
13
+ and then choose `flask` as template.
14
+ """
15
+
16
+ # example constant variable
17
+ NAME = "qablet_contracts"
@@ -0,0 +1,73 @@
1
+ """
2
+ Create timetables for Zero Coupon Bond and related contracts.
3
+ """
4
+
5
+ from qablet_contracts.timetable import timetable_from_dicts
6
+
7
+
8
+ def zcb_timetable(ccy: str, maturity: float) -> dict:
9
+ """Create timetable for a zero coupon bond.
10
+
11
+ Args:
12
+ ccy: the currency of the bond.
13
+ maturity: the maturity of the bond in years.
14
+
15
+ """
16
+
17
+ events = [
18
+ {
19
+ "track": "",
20
+ "time": maturity,
21
+ "op": "+",
22
+ "quantity": 1,
23
+ "unit": ccy,
24
+ } # get bond notional at bond expiration
25
+ ]
26
+ return timetable_from_dicts(events)
27
+
28
+
29
+ def zbp_timetable(
30
+ ccy: str, opt_maturity: float, bond_maturity: float, strike: float
31
+ ) -> dict:
32
+ """Create timetable for a zero coupon bond put.
33
+
34
+ Args:
35
+ ccy: the currency of the bond.
36
+ opt_maturity: the maturity of the option in years.
37
+ bond_maturity: the maturity of the option in years.
38
+ strike: the option strike.
39
+ """
40
+
41
+ events = [
42
+ {
43
+ "track": "",
44
+ "time": opt_maturity,
45
+ "op": ">",
46
+ "quantity": 0,
47
+ "unit": ccy,
48
+ }, # Choose greater of nothing or continue to remaining events
49
+ {
50
+ "track": "",
51
+ "time": opt_maturity,
52
+ "op": "+",
53
+ "quantity": strike,
54
+ "unit": ccy,
55
+ }, # get strike at expiration
56
+ {
57
+ "track": "",
58
+ "time": bond_maturity,
59
+ "op": "+",
60
+ "quantity": -1,
61
+ "unit": ccy,
62
+ }, # pay bond notional at bond expiration
63
+ ]
64
+ return timetable_from_dicts(events)
65
+
66
+
67
+ if __name__ == "__main__":
68
+ # Create a zero coupon bond timetable
69
+ timetable = zcb_timetable("USD", 1)
70
+ print("zcb:\n", timetable["events"].to_pandas())
71
+
72
+ timetable = zbp_timetable("USD", 0.5, 1.0, 0.95)
73
+ print("zbp:\n", timetable["events"].to_pandas())
@@ -0,0 +1,28 @@
1
+ """CLI interface for qablet_contracts project.
2
+
3
+ Be creative! do whatever you want!
4
+
5
+ - Install click or typer and create a CLI app
6
+ - Use builtin argparse
7
+ - Start a web application
8
+ - Import things from your .base module
9
+ """
10
+
11
+
12
+ def main(): # pragma: no cover
13
+ """
14
+ The main function executes on commands:
15
+ `python -m qablet_contracts` and `$ qablet_contracts `.
16
+
17
+ This is your program's entry point.
18
+
19
+ You can change this function to do whatever you want.
20
+ Examples:
21
+ * Run a test suite
22
+ * Run a server
23
+ * Do some other stuff
24
+ * Run a command line application (Click, Typer, ArgParse)
25
+ * List all available tasks
26
+ * Run an application (Flask, FastAPI, Django, etc.)
27
+ """
28
+ print("This will do something")
@@ -0,0 +1,39 @@
1
+ # Define the timetable struct
2
+
3
+ import pyarrow as pa
4
+
5
+ DICT_TYPE = pa.dictionary(pa.int64(), pa.string())
6
+ EVENT_SCHEMA = pa.schema(
7
+ [
8
+ pa.field("track", DICT_TYPE),
9
+ pa.field("time", pa.float64()),
10
+ pa.field("op", DICT_TYPE),
11
+ pa.field("quantity", pa.float64()),
12
+ pa.field("unit", DICT_TYPE),
13
+ ]
14
+ )
15
+
16
+
17
+ def timetable_from_dicts(events: list[dict]) -> dict:
18
+ """Create timetable from a list of dicts.
19
+
20
+ Args:
21
+ events: a list of dicts with the following fields:
22
+
23
+ - track: string
24
+ - time: float
25
+ - op: string
26
+ - quantity: float
27
+ - unit: string
28
+
29
+ Returns:
30
+ a timetable dictionary with the following fields:
31
+
32
+ - events: a pyarrow record batch
33
+ - expressions: a dict for expressions, batches, and snappers
34
+
35
+ """
36
+ return {
37
+ "events": pa.RecordBatch.from_pylist(events, schema=EVENT_SCHEMA),
38
+ "expressions": {},
39
+ }
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.1
2
+ Name: qablet_contracts
3
+ Version: 0.1.0
4
+ Summary: Awesome qablet_contracts created by qablet
5
+ Home-page: https://github.com/qablet/qablet-contracts/
6
+ Author: qablet
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: pyarrow
10
+ Requires-Dist: pandas
11
+ Requires-Dist: numpy
12
+ Provides-Extra: test
13
+ Requires-Dist: pytest; extra == "test"
14
+ Requires-Dist: coverage; extra == "test"
15
+ Requires-Dist: flake8; extra == "test"
16
+ Requires-Dist: black; extra == "test"
17
+ Requires-Dist: isort; extra == "test"
18
+ Requires-Dist: pytest-cov; extra == "test"
19
+ Requires-Dist: mypy; extra == "test"
20
+ Requires-Dist: gitchangelog; extra == "test"
21
+ Requires-Dist: mkdocs; extra == "test"
22
+ Requires-Dist: mkdocstrings; extra == "test"
23
+ Requires-Dist: pyarrow; extra == "test"
24
+ Requires-Dist: pandas; extra == "test"
25
+ Requires-Dist: numpy; extra == "test"
26
+ Requires-Dist: ruff; extra == "test"
27
+
28
+ # qablet_contracts
29
+
30
+ This is a work in progress.
31
+
32
+ [![codecov](https://codecov.io/gh/qablet/qablet-contracts/branch/main/graph/badge.svg?token=qablet-contracts_token_here)](https://codecov.io/gh/qablet/qablet-contracts)
33
+ [![CI](https://github.com/qablet/qablet-contracts/actions/workflows/main.yml/badge.svg)](https://github.com/qablet/qablet-contracts/actions/workflows/main.yml)
34
+
35
+ Awesome qablet_contracts created by qablet
36
+
37
+ ## Install it from PyPI
38
+
39
+ ```bash
40
+ pip install qablet_contracts
41
+ ```
42
+
43
+ ## What is qablet
44
+ TBD
45
+
46
+ ## How to use qablet-contracts
47
+ TBD
48
+
49
+ ## What is in this repo?
50
+ TBD
51
+
52
+ ## Provide feedback
53
+
54
+ ## Usage
55
+
56
+ ```py
57
+ from qablet_contracts import BaseClass
58
+ from qablet_contracts import base_function
59
+
60
+ BaseClass().base_method()
61
+ base_function()
62
+ ```
63
+
64
+ ```bash
65
+ $ python -m qablet_contracts
66
+ #or
67
+ $ qablet_contracts
68
+ ```
69
+
70
+ ## Development
71
+
72
+ TBD.
@@ -0,0 +1,26 @@
1
+ Containerfile
2
+ HISTORY.md
3
+ LICENSE
4
+ MANIFEST.in
5
+ README.md
6
+ setup.cfg
7
+ setup.py
8
+ docs/__init__.py
9
+ docs/examples/__init__.py
10
+ docs/specifications/__init__.py
11
+ qablet_contracts/VERSION
12
+ qablet_contracts/__init__.py
13
+ qablet_contracts/base.py
14
+ qablet_contracts/cli.py
15
+ qablet_contracts/timetable.py
16
+ qablet_contracts.egg-info/PKG-INFO
17
+ qablet_contracts.egg-info/SOURCES.txt
18
+ qablet_contracts.egg-info/dependency_links.txt
19
+ qablet_contracts.egg-info/entry_points.txt
20
+ qablet_contracts.egg-info/requires.txt
21
+ qablet_contracts.egg-info/top_level.txt
22
+ qablet_contracts/bond/__init__.py
23
+ qablet_contracts/bond/zero.py
24
+ tests/__init__.py
25
+ tests/conftest.py
26
+ tests/test_base.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ qablet_contracts = qablet_contracts.__main__:main
@@ -0,0 +1,19 @@
1
+ pyarrow
2
+ pandas
3
+ numpy
4
+
5
+ [test]
6
+ pytest
7
+ coverage
8
+ flake8
9
+ black
10
+ isort
11
+ pytest-cov
12
+ mypy
13
+ gitchangelog
14
+ mkdocs
15
+ mkdocstrings
16
+ pyarrow
17
+ pandas
18
+ numpy
19
+ ruff
@@ -0,0 +1,2 @@
1
+ docs
2
+ qablet_contracts
@@ -0,0 +1,7 @@
1
+ [flake8]
2
+ max-line-length = 119
3
+
4
+ [egg_info]
5
+ tag_build =
6
+ tag_date = 0
7
+
@@ -0,0 +1,46 @@
1
+ """Python setup.py for qablet_contracts package"""
2
+ import io
3
+ import os
4
+ from setuptools import find_packages, setup
5
+
6
+
7
+ def read(*paths, **kwargs):
8
+ """Read the contents of a text file safely.
9
+ >>> read("qablet_contracts", "VERSION")
10
+ '0.1.0'
11
+ >>> read("README.md")
12
+ ...
13
+ """
14
+
15
+ content = ""
16
+ with io.open(
17
+ os.path.join(os.path.dirname(__file__), *paths),
18
+ encoding=kwargs.get("encoding", "utf8"),
19
+ ) as open_file:
20
+ content = open_file.read().strip()
21
+ return content
22
+
23
+
24
+ def read_requirements(path):
25
+ return [
26
+ line.strip()
27
+ for line in read(path).split("\n")
28
+ if not line.startswith(('"', "#", "-", "git+"))
29
+ ]
30
+
31
+
32
+ setup(
33
+ name="qablet_contracts",
34
+ version=read("qablet_contracts", "VERSION"),
35
+ description="Awesome qablet_contracts created by qablet",
36
+ url="https://github.com/qablet/qablet-contracts/",
37
+ long_description=read("README.md"),
38
+ long_description_content_type="text/markdown",
39
+ author="qablet",
40
+ packages=find_packages(exclude=["tests", ".github"]),
41
+ install_requires=read_requirements("requirements.txt"),
42
+ entry_points={
43
+ "console_scripts": ["qablet_contracts = qablet_contracts.__main__:main"]
44
+ },
45
+ extras_require={"test": read_requirements("requirements-test.txt")},
46
+ )
File without changes
@@ -0,0 +1,14 @@
1
+ import sys
2
+ import pytest
3
+
4
+
5
+ # each test runs on cwd to its temp dir
6
+ @pytest.fixture(autouse=True)
7
+ def go_to_tmpdir(request):
8
+ # Get the fixture dynamically by its name.
9
+ tmpdir = request.getfixturevalue("tmpdir")
10
+ # ensure local test created packages can be imported
11
+ sys.path.insert(0, str(tmpdir))
12
+ # Chdir only for the duration of the test.
13
+ with tmpdir.as_cwd():
14
+ yield
@@ -0,0 +1,5 @@
1
+ from qablet_contracts.base import NAME
2
+
3
+
4
+ def test_base():
5
+ assert NAME == "qablet_contracts"