Module: date_or_tenor_entry

Expand source code
# Copyright (C) 2023-present The Project Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from dataclasses import dataclass
from cl.convince.entries.entry import Entry


@dataclass(slots=True, kw_only=True)
class DateOrTenorEntry(Entry):
    """
    Can be specified as either a date or a tenor (length).

    Notes:
        - Fields are additive, however some combinations are not used in capital markets
    """

    date: str | None = None
    """The only field if specified as a date."""

    years: int | None = None
    """Years component of the time interval (either this field or date can be specified but not both)."""

    months: int | None = None
    """Months component of the time interval (either this field or date can be specified but not both)."""

    weeks: int | None = None
    """Weeks component of the time interval (either this field or date can be specified but not both)."""

    days: int | None = None
    """Days component of the time interval (either this field or date can be specified but not both)."""

    business_days: int | None = None
    """Business days component of the time interval (either this field or date can be specified but not both)."""

Classes

class DateOrTenorEntry (*, entry_id: str = None, title: str = None, body: str | None = None, data: str | None = None, approved_by: UserKey | None = None, few_shot: bool | None = None, date: str | None = None, years: int | None = None, months: int | None = None, weeks: int | None = None, days: int | None = None, business_days: int | None = None)

Can be specified as either a date or a tenor (length).

Notes

  • Fields are additive, however some combinations are not used in capital markets
Expand source code
@dataclass(slots=True, kw_only=True)
class DateOrTenorEntry(Entry):
    """
    Can be specified as either a date or a tenor (length).

    Notes:
        - Fields are additive, however some combinations are not used in capital markets
    """

    date: str | None = None
    """The only field if specified as a date."""

    years: int | None = None
    """Years component of the time interval (either this field or date can be specified but not both)."""

    months: int | None = None
    """Months component of the time interval (either this field or date can be specified but not both)."""

    weeks: int | None = None
    """Weeks component of the time interval (either this field or date can be specified but not both)."""

    days: int | None = None
    """Days component of the time interval (either this field or date can be specified but not both)."""

    business_days: int | None = None
    """Business days component of the time interval (either this field or date can be specified but not both)."""

Ancestors

Static methods

def check_entry_id(entry_id: str) -> None

Inherited from: Entry.check_entry_id

Check that the unique identifier is compliant with the expected format.

def get_entry_id(record_type: str, title: str, body: str | None = None, data: str | None = None) -> str

Inherited from: Entry.get_entry_id

Create the unique identifier from parameters.

def get_key_type() -> Type

Inherited from: Entry.get_key_type

Return key type even when called from a record.

def parse_optional_bool(field_value: str | None, *, field_name: str | None = None) -> bool | None

Inherited from: Entry.parse_optional_bool

Parse an optional boolean value.

def parse_required_bool(field_value: str | None, *, field_name: str | None = None) -> bool

Inherited from: Entry.parse_required_bool

Parse an optional boolean value.

Fields

var approved_by -> UserKey | None

Inherited from: Entry.approved_by

User who recorded the approval.

var body -> str | None

Inherited from: Entry.body

Optional body of the entry if not completely described by the title (included in MD5 hash).

var business_days -> int | None

Business days component of the time interval (either this field or date can be specified but not both).

var data -> str | None

Inherited from: Entry.data

Optional supporting data in YAML format (included in MD5 hash).

var date -> str | None

The only field if specified as a date.

var days -> int | None

Days component of the time interval (either this field or date can be specified but not both).

var entry_id -> str

Inherited from: Entry.entry_id

Based on record type, title and MD5 hash of body and data if present, EntryUtil.create_id is used to generate.

var few_shot -> bool | None

Inherited from: Entry.few_shot

If True, use this entry as a few-shot example.

var months -> int | None

Months component of the time interval (either this field or date can be specified but not both).

var title -> str

Inherited from: Entry.title

Title of a long entry or complete description of a short one (included in MD5 hash).

var weeks -> int | None

Weeks component of the time interval (either this field or date can be specified but not both).

var years -> int | None

Years component of the time interval (either this field or date can be specified but not both).

Methods

def get_key(self) -> EntryKey

Inherited from: Entry.get_key

Return a new key object whose fields populated from self, do not return self.

def get_text(self) -> str

Inherited from: Entry.get_text

Get the complete text of the entry.

def init(self) -> None

Inherited from: Entry.init

Generate entry_id in ‘type: title’ format followed by an MD5 hash of body and data if present.

def init_all(self) -> None

Inherited from: Entry.init_all

Invoke ‘init’ for each class in the order from base to derived, then validate against schema.

def run_propose(self) -> None

Inherited from: Entry.run_propose

Generate or regenerate the proposed value.