Repository navigation
Expand file tree
/
Copy path__init__.py
More file actions
171 lines (133 loc) · 4.22 KB
/
Copy path__init__.py
File metadata and controls
171 lines (133 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# SPDX-License-Identifier: LicenseRef-Rateslib-Dual
#
# Copyright (c) 2026 Siffrorna Technology Limited
#
# Dual-licensed: Free Educational Licence or Paid Commercial Licence (commercial/professional use)
# Source-available, not open source.
#
# See LICENSE and https://rateslib.com/py/en/latest/i_licence.html for details,
# and/or contact info (at) rateslib (dot) com
####################################################################################################
from __future__ import annotations
from rateslib.rs import (
Adjuster,
Cal,
CalendarManager,
Frequency,
Imm,
NamedCal,
RollDay,
StubInference,
UnionCal,
)
from rateslib.scheduling.calendars import get_calendar
from rateslib.scheduling.convention import Convention
from rateslib.scheduling.dcfs import dcf
from rateslib.scheduling.frequency import add_tenor
from rateslib.scheduling.imm import get_imm, next_imm
from rateslib.scheduling.schedule import Schedule
Imm.__doc__ = """
Enumerable type for International Money-Market (IMM) date definitions.
For further information on these descriptors see the Rust low level docs
for :rust:`Imm <scheduling>`.
"""
StubInference.__doc__ = """
Enumerable type for :class:`~rateslib.scheduling.Schedule` stub inference.
"""
Adjuster.__doc__ = """
Enumerable type for date adjustment rules.
.. rubric:: Variants
.. ipython:: python
:suppress:
from rateslib.rs import Adjuster
variants = [item for item in Adjuster.__dict__ if \\
"__" != item[:2] and \\
item not in ['adjust', 'adjusts', 'to_json', 'reverse'] \
]
.. ipython:: python
variants
"""
RollDay.__doc__ = """
Enumerable type for roll days.
.. rubric:: Variants
.. ipython:: python
:suppress:
from rateslib.rs import RollDay
variants = ["Day(int)", "IMM()"]
.. ipython:: python
variants
"""
Frequency.__doc__ = """
Enumerable type for a scheduling frequency.
.. rubric:: Variants
.. ipython:: python
:suppress:
from rateslib.rs import Frequency
variants = ["BusDays(int, calendar)", "CalDays(int)", "Months(int, rollday | None)", "Zero()"]
.. ipython:: python
variants
"""
Cal.__doc__ = """
A business day calendar defined by weekends and a holiday list.
Parameters
----------
holidays: list[datetime]
A list of specific non-business days.
week_mask: list[int]
A list of days defined as weekends, e.g. [5,6] for Saturday and Sunday.
"""
UnionCal.__doc__ = """
A calendar defined by a business day intersection of multiple :class:`~rateslib.scheduling.Cal`
objects.
Parameters
----------
calendars: list[Cal]
A list of :class:`~rateslib.scheduling.Cal` objects whose combination will define the
business and non-business days.
settlement_calendars: list[Cal]
A list of :class:`~rateslib.scheduling.Cal` objects whose combination will define the
settleable and non-settleable days.
"""
NamedCal.__doc__ = """
A wrapped :class:`~rateslib.scheduling.Cal` or
:class:`~rateslib.scheduling.UnionCal` constructed with a string parsing syntax.
This instance can only be constructed from named :class:`~rateslib.scheduling.Cal` objects that
have already been populated to the ``calendars`` :class:`~rateslib.scheduling.CalendarManager`.
Each *NamedCal* uses data shared in memory and does **not** reconstruct or copy the entire
list of holidays for every instantiation of this class.
Parameters
----------
name: str
The names of the calendars to populate the ``calendars`` and ``settlement_calendars``
arguments of a :class:`~rateslib.scheduling.UnionCal`. The individual calendar names must
pre-exist in the :class:`~rateslib.scheduling.CalendarManager`. The pipe operator
separates the two fields.
Examples
--------
.. ipython:: python
:suppress:
from rateslib.scheduling import NamedCal, UnionCal
.. ipython:: python
named_cal = NamedCal("ldn,tgt|fed")
assert isinstance(named_cal.inner, UnionCal)
assert len(named_cal.inner.calendars) == 2
assert len(named_cal.inner.settlement_calendars) == 1
"""
__all__ = (
"Schedule",
"Cal",
"NamedCal",
"UnionCal",
"CalendarManager",
"Adjuster",
"Convention",
"Frequency",
"Imm",
"RollDay",
"StubInference",
"add_tenor",
"get_calendar",
"get_imm",
"next_imm",
"dcf",
)