diff options
| author | Shivesh Mandalia <shivesh.mandalia@outlook.com> | 2020-04-20 01:25:38 +0100 |
|---|---|---|
| committer | Shivesh Mandalia <shivesh.mandalia@outlook.com> | 2020-04-20 01:25:38 +0100 |
| commit | da67665b62c75fe10a1494e3bc7d944963127fc0 (patch) | |
| tree | 4b93630c020727ad65b3d06548cdbc9466cbe412 | |
| parent | 1c8649fdcd9f56cca5b191ae3cbaec4977569380 (diff) | |
| download | MCOptionPricing-da67665b62c75fe10a1494e3bc7d944963127fc0.tar.gz MCOptionPricing-da67665b62c75fe10a1494e3bc7d944963127fc0.zip | |
Add __slots__
| -rw-r--r-- | .flake8 | 4 | ||||
| -rw-r--r-- | utils/engine.py | 2 | ||||
| -rw-r--r-- | utils/enums.py | 12 | ||||
| -rw-r--r-- | utils/path.py | 1 | ||||
| -rw-r--r-- | utils/payoff.py | 4 |
5 files changed, 15 insertions, 8 deletions
@@ -106,7 +106,9 @@ hang-closing = True # Specify a list of codes to ignore. ignore = - W503 + W503, + E133, + E226 # Specify the list of error codes you wish Flake8 to report. select = E, diff --git a/utils/engine.py b/utils/engine.py index f4169ec..f1a36af 100644 --- a/utils/engine.py +++ b/utils/engine.py @@ -33,6 +33,7 @@ class MCResult: MC standard error. """ + __slots__ = ['price', 'stderr'] price: float stderr: float @@ -67,6 +68,7 @@ class PricingEngine: path=PathGenerator(S=100.0, r=0.1, div=0.01, vol=0.3)) """ + __slots__ = 'payoff', 'path' payoff: BasePayoff path: PathGenerator diff --git a/utils/enums.py b/utils/enums.py index aed4a97..5516698 100644 --- a/utils/enums.py +++ b/utils/enums.py @@ -25,17 +25,17 @@ class PPEnum(Enum): class OptionRight(PPEnum): """Right of an option.""" - Call = auto() - Put = auto() + Call: int = auto() + Put: int = auto() class BarrierUpDown(PPEnum): """Up or down type barrier option.""" - Up = auto() - Down = auto() + Up: int = auto() + Down: int = auto() class BarrierInOut(PPEnum): """In or out type barrier option.""" - In = auto() - Out = auto() + In: int = auto() + Out: int = auto() diff --git a/utils/path.py b/utils/path.py index 41474ef..a4d5732 100644 --- a/utils/path.py +++ b/utils/path.py @@ -52,6 +52,7 @@ class PathGenerator: PathGenerator(S=100.0, r=0.1, div=0.01, vol=0.3) """ + __slots__ = 'S', 'r', 'div', 'vol' S: Number r: Number div: Number diff --git a/utils/payoff.py b/utils/payoff.py index 7edeb87..0a2a439 100644 --- a/utils/payoff.py +++ b/utils/payoff.py @@ -24,6 +24,7 @@ __all__ = [ class BasePayoff(ABC): """Base class for calculating the payoff.""" + __slots__ = 'K', '_option_right' def __init__(self, K: Number, option_right: Union[AnyStr, OptionRight]) -> None: @@ -244,11 +245,12 @@ class DiscreteBarrierPayOff(BasePayoff): DiscreteBarrierPayOff(K=100, option_right=Call, B=90, barrier_updown=Down, barrier_inout=Out) """ + __slots__ = 'K', '_option_right', 'B', '_barrier_updown', '_barrier_inout' def __init__( self, - option_right: Union[AnyStr, OptionRight], K: Number, + option_right: Union[AnyStr, OptionRight], B: Number, barrier_updown: Union[AnyStr, BarrierUpDown], barrier_inout: Union[AnyStr, BarrierInOut] |
