aboutsummaryrefslogtreecommitdiffstats
path: root/utils/enums.py
blob: 6a607ea932a9d708be5327c67bf4fce2f2565557 (plain)
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
# author : S. Mandalia
#          shivesh.mandalia@outlook.com
#
# date   : March 19, 2020

"""
Enumeration utility classes.
"""

from enum import Enum, auto

__all__ = ['OptionRight', 'BarrierUpDown', 'BarrierInOut']


class PPEnum(Enum):
    """Enum with prettier printing."""

    def __repr__(self) -> str:
        return super().__repr__().split('.')[1].split(':')[0]

    def __str__(self) -> str:
        return super().__str__().split('.')[1]


class OptionRight(PPEnum):
    """Right of an option."""
    Call = auto()
    Put = auto()


class BarrierUpDown(PPEnum):
    """Up or down type barrier option."""
    Up = auto()
    Down = auto()


class BarrierInOut(PPEnum):
    """In or out type barrier option."""
    In = auto()
    Out = auto()