1 个不稳定版本
使用旧Rust 2015
0.0.0 | 2016年7月30日 |
---|
#30 在 #比率
10KB
104 行
该包(Rust库)提供实用函数(指标)来衡量公司的绩效(公司健康状况)。
用法
在您的Cargo.toml中包含此库,如下所示
[dependencies]
financial_ratios = "0.0.0" // preferably the latest version on crates.io
示例
extern crate financial_ratios;
use financial_ratios::{ earnings_per_share, return_on_assets };
fn main() {
let test_1 = earnings_per_share(5000., 500000.); // 0.01
let test_2 = return_on_assets(2000., 5000.); // 0.4
// and so on with the other apis just feed what's expected
// particularly the exact types
}
API | 参数 |
---|---|
current_ratio | (current_assets: f64, current_liabilities: f64) |
quick_ratio | (current_assets: f64, inventories: f64, current_liabilities: f64) |
cash_ratio | (cash: f64, current_liabilities: f64) |
debt_ratio | (total_liabilities: f64, total_assets: f64) |
times_interest_earned | (ebit: f64, interest_expense: f64) |
cash_coverage_ratio | (ebit: f64, depreciation: f64, interest_expense: f64) |
inventory_turnover | (cogs: f64, inventory: f64) |
receivables_turnover | (sales: f64, accounts_receivable: f64) |
total_asset_turnover | (sales: f64, total_assets: f64) |
profit_margin | (net_income: f64, sales: f64) |
return_on_assets | (net_income: f64, total_assets: f64) |
return_on_equity | (net_income: f64, total_owners_equity: f64) |
earnings_per_share | (net_income: f64, outstanding_shares: f64) |
请注意,所有输出都是 f64
类型,您可以根据项目需要选择合适的舍入精度。
除非指定,否则期望输入为浮点数。如果您传入整数,则程序将
panic
。
为了保持一致性,
rate
作为普通浮点数传递,而不是作为百分比 (%)
目的
我们可以节省一些谷歌搜索或翻阅维基百科的时间。所有公式都有测试用例。如果您觉得应该包含缺失的公式,请随时发送PR(最好先提出问题 😎)
请不用担心函数是否拥有任何内容。因为原语支持复制特性。
维护
在可预见的未来,我计划积极管理仓库,因此我将遵循销售员的座右铭“如果您打开它,我就会关闭”,这意味着我会迅速修复问题。
许可证
此库使用GPLv2软件许可证分发。
financial_ratios (rust library - crate)
Copyright (C) 2016 Mohamed Hayibor
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.