Coverage for rivapy/models/base_model.py: 80%
20 statements
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-05 14:27 +0000
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-05 14:27 +0000
1import abc
2from typing import Set
3from rivapy.tools.interfaces import FactoryObject
5class BaseModel(FactoryObject):
6 @abc.abstractmethod
7 def udls(self)->Set[str]:
8 """Return the name of all underlyings modeled
10 Returns:
11 Set[str]: Set of the modeled underlyings.
12 """
13 pass
16class BaseFwdModel(FactoryObject):
17 @abc.abstractmethod
18 def udls(self)->Set[str]:
19 """Return the name of all underlyings modeled
21 Returns:
22 Set[str]: Set of the modeled underlyings.
23 """
24 pass
26 @staticmethod
27 def get_key(udl:str, fwd_expiry: int)->str:
28 return udl+'_FWD'+str(fwd_expiry)
30 @staticmethod
31 def get_expiry_from_key(key: str)->int:
32 return int(key.split('_FWD')[-1])
34 @staticmethod
35 def get_udl_from_key(key: str)->int:
36 return key.split('_FWD')[0]