-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrebalance.py
executable file
·36 lines (27 loc) · 1.08 KB
/
rebalance.py
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
#!/usr/bin/env python
# SPDX-FileCopyrightText: 2022 Leroy Hopson <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0
# Usage: rebalance.py current_world current_nz current_vn new_amount
import sys
current_world = float(sys.argv[1])
current_nz = float(sys.argv[2])
current_vn = float(sys.argv[3])
new_amount = float(sys.argv[4])
new_total = current_world + current_nz + current_vn + new_amount
expected_world = new_total * 0.74
expected_nz = new_total * 0.19
expected_vn = new_total * 0.07
new_world = expected_world - current_world
new_nz = expected_nz - current_nz
new_vn = expected_vn - current_vn
print("### TO EACH ###")
print("World", round(new_world, 2))
print("NZ ", round(new_nz, 2))
print("VN ", round(new_vn, 2))
new_total = round(current_world + current_nz + new_amount, 2)
new_world = new_total * (74/93) - current_world
new_nz = new_total * (19/93) - current_nz
print("\n### World/NZ ONLY ###")
print("World", round(new_world, 2), "{}%".format(round(new_world / new_amount * 100, 2)))
print("NZ ", round(new_nz, 2), "{}%".format(round(new_nz / new_amount * 100, 2)))