Files
Freqtrade/tools/mise.py
Jérôme Delacotte c719a887d5 ajout export feather
2025-05-07 21:00:32 +02:00

21 lines
812 B
Python

def cumulative_loss_on_repeated_dips(initial_price=100, drop_percent=1.5, num_drops=20):
price = initial_price
total_invested = 0
total_value = 0
print(f"{'Step':>4} | {'Price':>8} | {'Invested':>10} | {'Total Value':>12} | {'Loss %':>8}")
print("-" * 52)
for i in range(1, num_drops + 1):
price *= (1 - drop_percent / 100)
total_invested += initial_price
total_value += price
loss_pct = (1 - total_value / total_invested) * 100
print(f"{i:>4} | {price:>8.2f} | {total_invested:>10.2f} | {total_value:>12.2f} | {loss_pct:>8.2f}")
final_loss_pct = (1 - total_value / total_invested) * 100
print("\n📉 Perte finale cumulée :", round(final_loss_pct, 2), "%")
# Exemple :
cumulative_loss_on_repeated_dips(drop_percent=1.5, num_drops=20)