detquantlib 3.0.1__tar.gz → 3.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: detquantlib
3
- Version: 3.0.1
3
+ Version: 3.0.2
4
4
  Summary: An internal library containing functions and classes that can be used across Quant models.
5
5
  Author: DET
6
6
  Requires-Python: >=3.10,<4.0
@@ -78,8 +78,8 @@ def calc_months_diff(
78
78
  date and end date, irrespective of the day. For example, suppose that start date
79
79
  is 15-Jan-2025 and end date is 3-Mar-2025. Then, the month difference between
80
80
  Jan-2025 and Mar-2025 is 2.
81
- - diff_method="time": Counts the month difference, accounting the day and time of the
82
- start and end dates. For example:
81
+ - diff_method="time": Counts the month difference, accounting for the day and time
82
+ of the start and end dates. For example:
83
83
  - Suppose that start date is 15-Jan-2025 and end date is 3-Mar-2025. Then:
84
84
  - start date + 1 months = 15-Feb-2025
85
85
  - start date + 2 months = 15-Mar-2025
@@ -103,7 +103,7 @@ def calc_months_diff(
103
103
  ValueError: Raises an error when the input argument 'diff_method' is invalid
104
104
  """
105
105
  # Input validation
106
- if end_date < start_date:
106
+ if end_date < start_date and diff_method != "month":
107
107
  raise ValueError("End date cannot be smaller than start date.")
108
108
 
109
109
  # Calculate month difference
@@ -34,13 +34,6 @@ def convert_delivery_start_date_to_maturity(
34
34
  # Make input product string lower case only
35
35
  product = product.lower()
36
36
 
37
- # Validate input dates
38
- if delivery_start_date < trading_date:
39
- raise ValueError(
40
- "Input argument 'delivery_start_date' cannot be smaller than input argument "
41
- "'trading_date'."
42
- )
43
-
44
37
  if product == "month":
45
38
  maturity = calc_months_diff(
46
39
  start_date=trading_date,
@@ -49,13 +42,13 @@ def convert_delivery_start_date_to_maturity(
49
42
  )
50
43
 
51
44
  elif product == "quarter":
52
- quarter = pd.Timestamp(trading_date).quarter
53
- year_start_date = datetime(trading_date.year, 1, 1)
54
- trading_quarter_start_date = year_start_date + relativedelta(months=((quarter - 1) * 3))
45
+ trading_quarter_start_date = convert_maturity_to_delivery_start_date(
46
+ trading_date=trading_date, maturity=0, product="quarter"
47
+ )
55
48
 
56
- quarter = pd.Timestamp(delivery_start_date).quarter
57
- year_start_date = datetime(delivery_start_date.year, 1, 1)
58
- delivery_quarter_start_date = year_start_date + relativedelta(months=((quarter - 1) * 3))
49
+ delivery_quarter_start_date = convert_maturity_to_delivery_start_date(
50
+ trading_date=delivery_start_date, maturity=0, product="quarter"
51
+ )
59
52
 
60
53
  months_diff = calc_months_diff(
61
54
  start_date=trading_quarter_start_date,
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "detquantlib"
3
- version = "3.0.1"
3
+ version = "3.0.2"
4
4
  description = "An internal library containing functions and classes that can be used across Quant models."
5
5
  authors = ["DET"]
6
6
  readme = "README.md"
File without changes
File without changes