AshenH commited on
Commit
500d236
·
verified ·
1 Parent(s): 94db2b6

Update tools/ts_preprocess.py

Browse files
Files changed (1) hide show
  1. tools/ts_preprocess.py +4 -0
tools/ts_preprocess.py CHANGED
@@ -5,6 +5,7 @@ from typing import List
5
 
6
  MONTH = "MS" # month-start frequency
7
 
 
8
  def _emi(principal: float, annual_rate: float, n_months: int) -> float:
9
  """
10
  EMI formula with monthly compounding.
@@ -19,6 +20,7 @@ def _emi(principal: float, annual_rate: float, n_months: int) -> float:
19
  fac = (1.0 + r) ** n_months
20
  return principal * r * fac / (fac - 1.0)
21
 
 
22
  def _project_deposit(principal: float, annual_rate: float, months: int) -> pd.DataFrame:
23
  """
24
  Monthly path for a deposit. Value compounds monthly.
@@ -31,6 +33,7 @@ def _project_deposit(principal: float, annual_rate: float, months: int) -> pd.Da
31
  bal = bal * (1.0 + r)
32
  return pd.DataFrame(data)
33
 
 
34
  def _project_asset(principal: float, annual_rate: float, tenor_months: int) -> pd.DataFrame:
35
  """
36
  Monthly amortization schedule for an asset/loan using EMI.
@@ -54,6 +57,7 @@ def _project_asset(principal: float, annual_rate: float, tenor_months: int) -> p
54
  bal = next_bal
55
  return pd.DataFrame(data)
56
 
 
57
  def build_timeseries(df: pd.DataFrame) -> pd.DataFrame:
58
  """
59
  Input df columns (example):
 
5
 
6
  MONTH = "MS" # month-start frequency
7
 
8
+
9
  def _emi(principal: float, annual_rate: float, n_months: int) -> float:
10
  """
11
  EMI formula with monthly compounding.
 
20
  fac = (1.0 + r) ** n_months
21
  return principal * r * fac / (fac - 1.0)
22
 
23
+
24
  def _project_deposit(principal: float, annual_rate: float, months: int) -> pd.DataFrame:
25
  """
26
  Monthly path for a deposit. Value compounds monthly.
 
33
  bal = bal * (1.0 + r)
34
  return pd.DataFrame(data)
35
 
36
+
37
  def _project_asset(principal: float, annual_rate: float, tenor_months: int) -> pd.DataFrame:
38
  """
39
  Monthly amortization schedule for an asset/loan using EMI.
 
57
  bal = next_bal
58
  return pd.DataFrame(data)
59
 
60
+
61
  def build_timeseries(df: pd.DataFrame) -> pd.DataFrame:
62
  """
63
  Input df columns (example):