-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathratios.go
171 lines (147 loc) · 5.82 KB
/
ratios.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// Copyright (c) 2019-2023 The goinvest/fin developers. All rights reserved.
// Project site: https://github.com/goinvest/fin
// Use of this source code is governed by a MIT-style license that
// can be found in the LICENSE file for the project.
package fin
///////////////////////////////////////////////////////////////////////////////
//
// Profitability Ratios
//
///////////////////////////////////////////////////////////////////////////////
// ReturnOnEquity tells what percentage of profit is made for every dollar of
// equity invested in the company.
//
// Source: https://financialintelligencebook.com
func ReturnOnEquity(netProfit, equity float64) float64 {
return netProfit / equity
}
///////////////////////////////////////////////////////////////////////////////
//
// Leverage Ratios
//
///////////////////////////////////////////////////////////////////////////////
// DebtToAssets measures the ratio of all debt (short-term debt and long-term
// debt, but not other liabilities) to all assets.
func DebtToAssets(debt, assets float64) float64 {
return debt / assets
}
// DebtToEquity measures the ratio of all debt (short-term debt and long-term
// debt, but not other liabilities) to shareholders' equity.
func DebtToEquity(debt, equity float64) float64 {
return debt / equity
}
// LiabilitiesToAssets measures the ratio of total liabilities to total assets.
func LiabilitiesToAssets(liabilities, assets float64) float64 {
return liabilities / assets
}
// LiabilitiesToEquity measures the ratio of total liabilities to total
// shareholders' equity.
func LiabilitiesToEquity(liabilities, equity float64) float64 {
return liabilities / equity
}
// EquityMultiplier ratio is the factor by which the return on assets is
// multiplied to determine the return on equity. It is defined as the ratio of
// total assets to common equity. [Source: Financial Management: Theory &
// Practice, 16th ed.]
func EquityMultiplier(assets, equity float64) float64 {
return assets / equity
}
// TimesInterestEarned ratio, also called the interest coverage ratio, is
// determined by dividing earnings before interest and taxes (EBIT) by the
// interest expense. [Source: Financial Management: Theory & Practice, 16th
// ed.]
func TimesInterestEarned(ebit, interest float64) float64 {
return ebit / interest
}
// InterestCoverage calculates the ratio of many times it can pay its annual
// interest charges.
//
// Source: https://financialintelligencebook.com
func InterestCoverage(operatingProfit, interest float64) float64 {
return operatingProfit / interest
}
///////////////////////////////////////////////////////////////////////////////
//
// Liquidity Ratios
//
///////////////////////////////////////////////////////////////////////////////
// CurrentRatio measures a copmany's current assets against its current
// liabilities.
//
// Source: https://financialintelligencebook.com
func CurrentRatio(currentAssets, currentLiabilities float64) float64 {
return currentAssets / currentLiabilities
}
// QuickRatio, also known as the acid test, assesses how quickly a company
// could pay off their short-term debt without waiting to sell inventory.
//
// Source: https://financialintelligencebook.com
func QuickRatio(currentAssets, currentLiabilities, inventory float64) float64 {
return (currentAssets - inventory) / currentLiabilities
}
///////////////////////////////////////////////////////////////////////////////
//
// Efficiency Ratios
//
///////////////////////////////////////////////////////////////////////////////
// DaysInInventory measures the number of days inventory stays in the system.
//
// Source: https://financialintelligencebook.com
func DaysInInventory(inventory, cogs float64, days int) float64 {
return inventory / (cogs / float64(days))
}
// DaysInInventory360 measures the number of days inventory stays in the system
// assuming 360 days for the year.
//
// Source: https://financialintelligencebook.com
func DaysInInventory360(inventory, cogs float64) float64 {
return DaysInInventory(inventory, cogs, 360)
}
// InventoryTurns measures how many times inventory turns over in a year.
//
// Source: https://financialintelligencebook.com
func InventoryTurns(inventory, cogs float64) float64 {
return cogs / inventory
}
// DaysSalesOutstanding measures the average time it takes to collect the
// cash from sales.
//
// Source: https://financialintelligencebook.com
func DaysSalesOutstanding(receivables, revenues float64, days int) float64 {
return receivables / (revenues / float64(days))
}
// DaysSalesOutstanding360 measures the average time it takes to collect the
// cash from sales assuming 360 days for the year.
//
// Source: https://financialintelligencebook.com
func DaysSalesOutstanding360(receivables, revenues float64) float64 {
return DaysSalesOutstanding(receivables, revenues, 360)
}
// DaysPayableOutstanding shows the average number of days it take a company to
// pay its own outstanding invoices.
//
// Source: https://financialintelligencebook.com
func DaysPayableOutstanding(payables, cogs float64, days int) float64 {
return payables / (cogs / float64(days))
}
// DaysPayableOutstanding360 shows the average number of days it take a company to
// pay its own outstanding invoices assuming 360 days for the year.
//
// Source: https://financialintelligencebook.com
func DaysPayableOutstanding360(payables, cogs float64) float64 {
return DaysPayableOutstanding(payables, cogs, 360)
}
// PPETurnover calculates the amount of revenue generated per dollar invested
// in Property, Plant, and Equipment (PPE).
//
// Source: https://financialintelligencebook.com
func PPETurnover(revenue, ppe float64) float64 {
return revenue / ppe
}
// TotalAssetTurnover calculates the amount of revenue generated per dollar
// invested in all assets.
//
// Source: https://financialintelligencebook.com
func TotalAssetTurnover(revenue, assets float64) float64 {
return revenue / assets
}