betterfinance1 0.1.0__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.
- betterfinance1-0.1.0/PKG-INFO +63 -0
- betterfinance1-0.1.0/README.md +54 -0
- betterfinance1-0.1.0/pyproject.toml +20 -0
- betterfinance1-0.1.0/setup.cfg +4 -0
- betterfinance1-0.1.0/src/betterfinance1/__init__.py +12 -0
- betterfinance1-0.1.0/src/betterfinance1/core.py +35 -0
- betterfinance1-0.1.0/src/betterfinance1.egg-info/PKG-INFO +63 -0
- betterfinance1-0.1.0/src/betterfinance1.egg-info/SOURCES.txt +10 -0
- betterfinance1-0.1.0/src/betterfinance1.egg-info/dependency_links.txt +1 -0
- betterfinance1-0.1.0/src/betterfinance1.egg-info/requires.txt +2 -0
- betterfinance1-0.1.0/src/betterfinance1.egg-info/top_level.txt +1 -0
- betterfinance1-0.1.0/tests/test_public_api.py +18 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: betterfinance1
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A small collection of financial and numerical helper functions.
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: numpy>=1.24
|
|
8
|
+
Requires-Dist: scipy>=1.10
|
|
9
|
+
|
|
10
|
+
# betterfinance1
|
|
11
|
+
|
|
12
|
+
一个包含四个金融与数值分析函数的 Python 工具库。
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
python -m pip install betterfinance1
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 使用
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from betterfinance1 import (
|
|
24
|
+
pv,
|
|
25
|
+
linear_volatility_score,
|
|
26
|
+
boundary_width,
|
|
27
|
+
flexibility,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# 债券现值
|
|
31
|
+
bond_value = pv(r=0.05, cf=5, t=3, fv=100)
|
|
32
|
+
|
|
33
|
+
# 数列线性波动评分
|
|
34
|
+
volatility_score = linear_volatility_score([10, 12, 11, 15, 14])
|
|
35
|
+
|
|
36
|
+
# 预期变化区间宽度
|
|
37
|
+
width = boundary_width([10, 12, 15, 11], 5)
|
|
38
|
+
|
|
39
|
+
# 灵活性指标
|
|
40
|
+
flexibility_score = flexibility([10, 11, 13, 12, 16, 18])
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 函数
|
|
44
|
+
|
|
45
|
+
| 函数 | 参数 | 用途 |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `pv(r, cf, t, fv)` | 利率、票息、期限、面值 | 债券现值计算 |
|
|
48
|
+
| `linear_volatility_score(a)` | 数值序列 | 将差分序列的波动程度转换为评分 |
|
|
49
|
+
| `boundary_width(Alice, Tom)` | 数值序列、区间划分数 | 计算预期变化区间宽度 |
|
|
50
|
+
| `flexibility(a)` | 数值序列 | 根据标准化差分和峰度计算灵活性指标 |
|
|
51
|
+
|
|
52
|
+
## 依赖
|
|
53
|
+
|
|
54
|
+
安装本库时会自动安装 NumPy 和 SciPy。
|
|
55
|
+
|
|
56
|
+
## 版本
|
|
57
|
+
|
|
58
|
+
当前版本:`0.1.0`。
|
|
59
|
+
|
|
60
|
+
## 说明
|
|
61
|
+
|
|
62
|
+
本包保留了原始文件中的四个函数实现及其计算逻辑。函数输入条件、数值边界和公式行为请在正式使用前自行验证。
|
|
63
|
+
本项目暂未附加开源许可证;正式公开发布前,请确定你希望采用的许可证。
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# betterfinance1
|
|
2
|
+
|
|
3
|
+
一个包含四个金融与数值分析函数的 Python 工具库。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python -m pip install betterfinance1
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from betterfinance1 import (
|
|
15
|
+
pv,
|
|
16
|
+
linear_volatility_score,
|
|
17
|
+
boundary_width,
|
|
18
|
+
flexibility,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# 债券现值
|
|
22
|
+
bond_value = pv(r=0.05, cf=5, t=3, fv=100)
|
|
23
|
+
|
|
24
|
+
# 数列线性波动评分
|
|
25
|
+
volatility_score = linear_volatility_score([10, 12, 11, 15, 14])
|
|
26
|
+
|
|
27
|
+
# 预期变化区间宽度
|
|
28
|
+
width = boundary_width([10, 12, 15, 11], 5)
|
|
29
|
+
|
|
30
|
+
# 灵活性指标
|
|
31
|
+
flexibility_score = flexibility([10, 11, 13, 12, 16, 18])
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 函数
|
|
35
|
+
|
|
36
|
+
| 函数 | 参数 | 用途 |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| `pv(r, cf, t, fv)` | 利率、票息、期限、面值 | 债券现值计算 |
|
|
39
|
+
| `linear_volatility_score(a)` | 数值序列 | 将差分序列的波动程度转换为评分 |
|
|
40
|
+
| `boundary_width(Alice, Tom)` | 数值序列、区间划分数 | 计算预期变化区间宽度 |
|
|
41
|
+
| `flexibility(a)` | 数值序列 | 根据标准化差分和峰度计算灵活性指标 |
|
|
42
|
+
|
|
43
|
+
## 依赖
|
|
44
|
+
|
|
45
|
+
安装本库时会自动安装 NumPy 和 SciPy。
|
|
46
|
+
|
|
47
|
+
## 版本
|
|
48
|
+
|
|
49
|
+
当前版本:`0.1.0`。
|
|
50
|
+
|
|
51
|
+
## 说明
|
|
52
|
+
|
|
53
|
+
本包保留了原始文件中的四个函数实现及其计算逻辑。函数输入条件、数值边界和公式行为请在正式使用前自行验证。
|
|
54
|
+
本项目暂未附加开源许可证;正式公开发布前,请确定你希望采用的许可证。
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "betterfinance1"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A small collection of financial and numerical helper functions."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"numpy>=1.24",
|
|
13
|
+
"scipy>=1.10",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[tool.setuptools]
|
|
17
|
+
package-dir = {"" = "src"}
|
|
18
|
+
|
|
19
|
+
[tool.setuptools.packages.find]
|
|
20
|
+
where = ["src"]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
def pv(r, cf, t, fv):
|
|
2
|
+
"The present value of bond."
|
|
3
|
+
i = 1
|
|
4
|
+
pv = 0
|
|
5
|
+
while i < int(t)-1:
|
|
6
|
+
pv = pv+cf/((1+r)**i)
|
|
7
|
+
i = i+1
|
|
8
|
+
pv = pv+(cf + fv)/((1+r)**t)
|
|
9
|
+
return pv
|
|
10
|
+
|
|
11
|
+
def linear_volatility_score(a):
|
|
12
|
+
"Let's translate the volatility of a list into a float value between 0 and 100!"
|
|
13
|
+
import numpy as np
|
|
14
|
+
b = np.diff(a)
|
|
15
|
+
volatility = np.std(b)/abs(np.mean(b))
|
|
16
|
+
score = 100/(1+volatility)
|
|
17
|
+
return score
|
|
18
|
+
|
|
19
|
+
def boundary_width(Alice, Tom):
|
|
20
|
+
"What's your expectation of the appearance of change?"
|
|
21
|
+
m = max(Alice)
|
|
22
|
+
n = min(Alice)
|
|
23
|
+
expected_width=(m-n)/int(Tom)
|
|
24
|
+
return expected_width
|
|
25
|
+
|
|
26
|
+
def flexibility(a):
|
|
27
|
+
"The most optimistic growth behavior of a list."
|
|
28
|
+
import numpy as np
|
|
29
|
+
ar = np.array(a)/np.mean(a)
|
|
30
|
+
b = np.diff(ar)
|
|
31
|
+
from scipy.stats import kurtosis
|
|
32
|
+
c = max(b)
|
|
33
|
+
k = kurtosis(b, fisher = True)
|
|
34
|
+
flexibility = c/(np.mean(ar)*k)
|
|
35
|
+
return flexibility
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: betterfinance1
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A small collection of financial and numerical helper functions.
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: numpy>=1.24
|
|
8
|
+
Requires-Dist: scipy>=1.10
|
|
9
|
+
|
|
10
|
+
# betterfinance1
|
|
11
|
+
|
|
12
|
+
一个包含四个金融与数值分析函数的 Python 工具库。
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
python -m pip install betterfinance1
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 使用
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from betterfinance1 import (
|
|
24
|
+
pv,
|
|
25
|
+
linear_volatility_score,
|
|
26
|
+
boundary_width,
|
|
27
|
+
flexibility,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# 债券现值
|
|
31
|
+
bond_value = pv(r=0.05, cf=5, t=3, fv=100)
|
|
32
|
+
|
|
33
|
+
# 数列线性波动评分
|
|
34
|
+
volatility_score = linear_volatility_score([10, 12, 11, 15, 14])
|
|
35
|
+
|
|
36
|
+
# 预期变化区间宽度
|
|
37
|
+
width = boundary_width([10, 12, 15, 11], 5)
|
|
38
|
+
|
|
39
|
+
# 灵活性指标
|
|
40
|
+
flexibility_score = flexibility([10, 11, 13, 12, 16, 18])
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 函数
|
|
44
|
+
|
|
45
|
+
| 函数 | 参数 | 用途 |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `pv(r, cf, t, fv)` | 利率、票息、期限、面值 | 债券现值计算 |
|
|
48
|
+
| `linear_volatility_score(a)` | 数值序列 | 将差分序列的波动程度转换为评分 |
|
|
49
|
+
| `boundary_width(Alice, Tom)` | 数值序列、区间划分数 | 计算预期变化区间宽度 |
|
|
50
|
+
| `flexibility(a)` | 数值序列 | 根据标准化差分和峰度计算灵活性指标 |
|
|
51
|
+
|
|
52
|
+
## 依赖
|
|
53
|
+
|
|
54
|
+
安装本库时会自动安装 NumPy 和 SciPy。
|
|
55
|
+
|
|
56
|
+
## 版本
|
|
57
|
+
|
|
58
|
+
当前版本:`0.1.0`。
|
|
59
|
+
|
|
60
|
+
## 说明
|
|
61
|
+
|
|
62
|
+
本包保留了原始文件中的四个函数实现及其计算逻辑。函数输入条件、数值边界和公式行为请在正式使用前自行验证。
|
|
63
|
+
本项目暂未附加开源许可证;正式公开发布前,请确定你希望采用的许可证。
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/betterfinance1/__init__.py
|
|
4
|
+
src/betterfinance1/core.py
|
|
5
|
+
src/betterfinance1.egg-info/PKG-INFO
|
|
6
|
+
src/betterfinance1.egg-info/SOURCES.txt
|
|
7
|
+
src/betterfinance1.egg-info/dependency_links.txt
|
|
8
|
+
src/betterfinance1.egg-info/requires.txt
|
|
9
|
+
src/betterfinance1.egg-info/top_level.txt
|
|
10
|
+
tests/test_public_api.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
betterfinance1
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
|
|
3
|
+
import betterfinance1
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class PublicApiTests(unittest.TestCase):
|
|
7
|
+
def test_four_functions_are_exported(self):
|
|
8
|
+
for name in (
|
|
9
|
+
"pv",
|
|
10
|
+
"linear_volatility_score",
|
|
11
|
+
"boundary_width",
|
|
12
|
+
"flexibility",
|
|
13
|
+
):
|
|
14
|
+
self.assertTrue(callable(getattr(betterfinance1, name)))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
if __name__ == "__main__":
|
|
18
|
+
unittest.main()
|