Fix profit/loss calculation

This commit is contained in:
2023-01-06 08:52:15 +00:00
parent 1bab2a729b
commit ae42d9b223
4 changed files with 39 additions and 19 deletions

View File

@@ -1,3 +1,6 @@
from core.trading.market import to_currency
def check_max_loss(risk_model, initial_balance, account_balance):
"""
Check that the account balance is within the max loss limit.
@@ -15,6 +18,8 @@ def check_max_risk(risk_model, account_trades):
total_risk = 0
for trade in account_trades:
max_tmp = []
# Need to calculate the max risk in base account currency
# Percentages relate to the price movement, without accounting the size of the trade
if "stop_loss_percent" in trade:
max_tmp.append(trade["stop_loss_percent"])
if "trailing_stop_loss_percent" in trade: