Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tamilselvanarjun committed Mar 18, 2024
2 parents 321f29c + acba9ef commit 99e48b5
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 18 deletions.
5 changes: 2 additions & 3 deletions build/lib/finmodels/dcf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# financial_models/dcf.py
def calculate_dcf(cash_flows, discount_rate):
"""
Calculate the Discounted Cash Flow (DCF) valuation.
Expand All @@ -10,5 +9,5 @@ def calculate_dcf(cash_flows, discount_rate):
Returns:
- DCF value
"""
dcf_value = sum(cf / (1 + discount_rate) ** (i + 1) for i, cf in enumerate(cash_flows))
return dcf_value
dcf_value = sum(cf / (1 + discount_rate) ** i for i, cf in enumerate(cash_flows))
return dcf_value
3 changes: 1 addition & 2 deletions build/lib/finmodels/ipo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self, initial_valuation, funds_raised, operating_income, growth_rat

def calculate_ipo_valuation(self):
# Calculate the IPO valuation using a simple discounted cash flow (DCF) model
discount_factor = 1 / (1 + self.growth_rate)
discount_factor = 1 + self.growth_rate
future_cash_flows = [self.operating_income * (discount_factor ** year) for year in range(1, self.years + 1)]
total_cash_flows = sum(future_cash_flows)
ipo_valuation = self.initial_valuation + total_cash_flows + self.funds_raised
Expand All @@ -18,7 +18,6 @@ def print_summary(self):
ipo_valuation = self.calculate_ipo_valuation()
print(f"IPO Valuation after {self.years} years: ${ipo_valuation:,.2f}")


# Example usage
#initial_valuation = 500000000 # Initial company valuation before IPO
#funds_raised = 100000000 # Funds raised during the IPO
Expand Down
9 changes: 6 additions & 3 deletions build/lib/finmodels/portfolio_optimization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# financial_models/portfolio_optimization.py
import numpy as np
import cvxpy as cp

Expand All @@ -11,7 +10,7 @@ def optimize_portfolio(expected_returns, covariance_matrix):
- covariance_matrix: Covariance matrix of asset returns
Returns:
- Optimal portfolio weights
- Optimal portfolio weights if successful, None otherwise
"""
num_assets = len(expected_returns)

Expand All @@ -30,4 +29,8 @@ def optimize_portfolio(expected_returns, covariance_matrix):
problem = cp.Problem(objective, constraints)
problem.solve()

return weights.value
if problem.status == 'optimal':
return weights.value
else:
print("Optimization problem could not be solved.")
return None
Binary file removed dist/finmodels-2.0.0-py3-none-any.whl
Binary file not shown.
Binary file removed dist/finmodels-2.0.0.tar.gz
Binary file not shown.
Binary file added dist/finmodels-2.0.3-py3-none-any.whl
Binary file not shown.
Binary file added dist/finmodels-2.0.3.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion finmodels.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: finmodels
Version: 2.0.0
Version: 2.0.3
Summary: finmodels is a Python package that provides various financial models for analysis and optimization.
Home-page: https://github.com/arjunlimat/finmodels
Author: Tamilselvan_Arjunan
Expand Down
5 changes: 2 additions & 3 deletions finmodels/dcf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# financial_models/dcf.py
def calculate_dcf(cash_flows, discount_rate):
"""
Calculate the Discounted Cash Flow (DCF) valuation.
Expand All @@ -10,5 +9,5 @@ def calculate_dcf(cash_flows, discount_rate):
Returns:
- DCF value
"""
dcf_value = sum(cf / (1 + discount_rate) ** (i + 1) for i, cf in enumerate(cash_flows))
return dcf_value
dcf_value = sum(cf / (1 + discount_rate) ** i for i, cf in enumerate(cash_flows))
return dcf_value
3 changes: 1 addition & 2 deletions finmodels/ipo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self, initial_valuation, funds_raised, operating_income, growth_rat

def calculate_ipo_valuation(self):
# Calculate the IPO valuation using a simple discounted cash flow (DCF) model
discount_factor = 1 / (1 + self.growth_rate)
discount_factor = 1 + self.growth_rate
future_cash_flows = [self.operating_income * (discount_factor ** year) for year in range(1, self.years + 1)]
total_cash_flows = sum(future_cash_flows)
ipo_valuation = self.initial_valuation + total_cash_flows + self.funds_raised
Expand All @@ -18,7 +18,6 @@ def print_summary(self):
ipo_valuation = self.calculate_ipo_valuation()
print(f"IPO Valuation after {self.years} years: ${ipo_valuation:,.2f}")


# Example usage
#initial_valuation = 500000000 # Initial company valuation before IPO
#funds_raised = 100000000 # Funds raised during the IPO
Expand Down
9 changes: 6 additions & 3 deletions finmodels/portfolio_optimization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# financial_models/portfolio_optimization.py
import numpy as np
import cvxpy as cp

Expand All @@ -11,7 +10,7 @@ def optimize_portfolio(expected_returns, covariance_matrix):
- covariance_matrix: Covariance matrix of asset returns
Returns:
- Optimal portfolio weights
- Optimal portfolio weights if successful, None otherwise
"""
num_assets = len(expected_returns)

Expand All @@ -30,4 +29,8 @@ def optimize_portfolio(expected_returns, covariance_matrix):
problem = cp.Problem(objective, constraints)
problem.solve()

return weights.value
if problem.status == 'optimal':
return weights.value
else:
print("Optimization problem could not be solved.")
return None
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='finmodels',
version='2.0.0',
version='2.0.3',
packages=find_packages(),
install_requires=[
'numpy',
Expand Down

0 comments on commit 99e48b5

Please sign in to comment.