File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -53,17 +53,21 @@ def etl_percentage(dic_金字塔下單資料:dict,
53
53
flt_累計下跌百分比 = 0
54
54
flt_最終價格 = 0
55
55
56
- for key ,value in dic_金字塔下單資料 .items ():
56
+ for key ,value in dic_金字塔下單資料 .items ():
57
+ flt_百分比 = 0
57
58
# 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_百分比 ))
59
62
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_累計百分比 ))
62
66
63
67
# 計算累計下跌百分比 : ((起始價格 - 本階價格)/起始價格)*100
64
68
flt_累計下跌百分比 += get下跌百分比 (flt_起始價格 ,dic_金字塔下單資料_ret [key ]['價格' ])
65
69
# flt_累計下跌百分比 += ((flt_起始價格 - dic_金字塔下單資料_ret[key]['價格'])/flt_起始價格)*100
66
- dic_金字塔下單資料_ret [key ]["累計下跌百分比" ]= flt_累計下跌百分比
70
+ dic_金字塔下單資料_ret [key ]["累計下跌百分比" ]= float ( "{:.2f}" . format ( flt_累計下跌百分比 ))
67
71
flt_最終價格 = dic_金字塔下單資料_ret [key ]['價格' ]
68
72
69
73
dic_金字塔下單資料_ret ["最終價格" ] = flt_最終價格
You can’t perform that action at this time.
0 commit comments