File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ /// calculate whether the account has satisfy the YearProfit condition to sell out or not.
2
+ import math
3
+
4
+ global YearProfit ### integer
5
+
6
+ def SetProfit(val):
7
+ global YearProfit
8
+ YearProfit = val
9
+
10
+ def CalDailyPro():
11
+ global YearProfit
12
+ return math.pow(YearProfit,1/360)
13
+
14
+ def CalDaysPro(day_num):
15
+ DailyPro = CalDailyPro()
16
+ return math.pow(DailyPro,day_num)
17
+
18
+ def NeedDaysIncome(day_num,init_money,redemption_rate = 0.02):
19
+ DaysPro = CalDaysPro(day_num)
20
+ DaysIncome = init_money * DaysPro
21
+ return DaysIncome/(1-redemption_rate)
22
+
23
+ def JudgeSellOrNot(day_num,init_money,now_money,redemption_rate = 0.02):
24
+ NeedIncome = NeedDaysIncome(day_num,init_money,redemption_rate)
25
+ if(now_money > NeedIncome):
26
+ return "Sell"
27
+ else:
28
+ return "NotSell,wait..."
29
+
30
+
31
+ SetProfit(3)
32
+ day_num = 7
33
+ init_money = 200
34
+ now_money = 209
35
+ print(NeedDaysIncome(day_num,init_money))
36
+ print(JudgeSellOrNot(day_num,init_money,now_money))
You can’t perform that action at this time.
0 commit comments