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

@@ -134,14 +134,10 @@ class LiveTradingTestCase(ElasticMock, LiveBase, TestCase):
expected_sl_percent = D(2 - self.commission)
actual_tp_percent = trades_converted[0]["take_profit_percent"]
actual_sl_percent = trades_converted[0]["stop_loss_percent"]
print("actual_tp_percent", actual_tp_percent)
print("actual_sl_percent", actual_sl_percent)
tp_percent_difference = abs(expected_tp_percent - actual_tp_percent)
sl_percent_difference = abs(expected_sl_percent - actual_sl_percent)
max_difference = D(0.08) # depends on market conditions
print("TP percent difference: {}".format(tp_percent_difference))
print("SL percent difference: {}".format(sl_percent_difference))
self.assertLess(tp_percent_difference, max_difference)
self.assertLess(sl_percent_difference, max_difference)