Skip to content

Commit d820896

Browse files
committed
調整顯示的百分比位數為2位
1 parent ef52d82 commit d820896

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

algo_pyramid.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,21 @@ def etl_percentage(dic_金字塔下單資料:dict,
5353
flt_累計下跌百分比 = 0
5454
flt_最終價格=0
5555

56-
for key,value in dic_金字塔下單資料.items():
56+
for key,value in dic_金字塔下單資料.items():
57+
flt_百分比 = 0
5758
# dic_金字塔下單資料_ret[key]["百分比"]= (dic_金字塔下單資料_ret[key]["金額"]/flt_一組金字塔的加總金額)*100
58-
dic_金字塔下單資料_ret[key]["百分比"] = get本階投入資金百分比(flt_一組金字塔的加總金額,dic_金字塔下單資料_ret[key]["金額"])
59+
60+
flt_百分比 = get本階投入資金百分比(flt_一組金字塔的加總金額,dic_金字塔下單資料_ret[key]["金額"])
61+
dic_金字塔下單資料_ret[key]["百分比"] = float("{:.2f}".format(flt_百分比))
5962

60-
flt_累計百分比 += dic_金字塔下單資料_ret[key]["百分比"]
61-
dic_金字塔下單資料_ret[key]["累計百分比"]= flt_累計百分比
63+
flt_累計百分比 += flt_百分比
64+
# float("{:.2f}".format(13.949999999999999))
65+
dic_金字塔下單資料_ret[key]["累計百分比"]= float("{:.2f}".format(flt_累計百分比))
6266

6367
# 計算累計下跌百分比 : ((起始價格 - 本階價格)/起始價格)*100
6468
flt_累計下跌百分比 += get下跌百分比(flt_起始價格,dic_金字塔下單資料_ret[key]['價格'])
6569
# flt_累計下跌百分比 += ((flt_起始價格 - dic_金字塔下單資料_ret[key]['價格'])/flt_起始價格)*100
66-
dic_金字塔下單資料_ret[key]["累計下跌百分比"]= flt_累計下跌百分比
70+
dic_金字塔下單資料_ret[key]["累計下跌百分比"]= float("{:.2f}".format(flt_累計下跌百分比))
6771
flt_最終價格=dic_金字塔下單資料_ret[key]['價格']
6872

6973
dic_金字塔下單資料_ret["最終價格"] = flt_最終價格

0 commit comments

Comments
 (0)