high = 1800
low = 1200
ratio_number = 5
# ~ ratio1 = [0.2,0.24,0.26,0.3]
ratio1 = [0.15,0.18,0.2,0.23,0.25]
distance = high – low
final_result = [high – distance /ratio_number * (i+1) for i in range(ratio_number)]
base_money = 10000
available_money = base_money
final_money = 0
total_units = 0
print("高:" +str(high)+ ",低:" + str(low))
print("区间:" + str(distance) + ',间隔:' + str(int(distance/ratio_number)))
print("等比例:"+ str(final_result))
print("跌幅:-" + str(round(distance / high *100,2)) +"%")
for r,f in zip(ratio1, final_result):
total_units = total_units + r * base_money / f
available_money = available_money – r * base_money
final_money = total_units * f + available_money
print("buy:" + str(r*base_money) + ",final_money:" + str(round(final_money,2)))
print("最终损益:" + str(round((final_money – base_money) /base_money *100,2)) + "%")
half_price = high – 0.4 * distance
half_earning = round(((high – 0.4 * distance) *total_units – base_money) /base_money *100,2)
print("上涨一半的收益:" + str(half_earning) + "%,总金额:"+str(round(half_price*total_units,2)) +",价格:" + str(half_price))
total_money = total_units * 1/3 * half_price + total_units * 2/3 * (high – ratio1[0]* distance)
print("最终收益:" + str(round(total_money/base_money*100,2)) + "%,总金额:"+str(round(total_money,2)) +",价格:" + str(high – ratio1[0]* distance))