Improve dry-run calculations

This commit is contained in:
Matthias
2019-12-15 10:26:56 +01:00
parent f0bbc75038
commit 5a5741878c
4 changed files with 36 additions and 6 deletions

View File

@@ -232,8 +232,8 @@ class FreqtradeBot:
# Check if stake_amount is fulfilled
if available_amount < stake_amount:
raise DependencyException(
f"Available balance({available_amount} {self.config['stake_currency']}) is "
f"lower than stake amount({stake_amount} {self.config['stake_currency']})"
f"Available balance ({available_amount} {self.config['stake_currency']}) is "
f"lower than stake amount ({stake_amount} {self.config['stake_currency']})"
)
return stake_amount

View File

@@ -54,21 +54,20 @@ class Wallets:
def _update_dry(self) -> None:
""" Update from database in dry-run mode"""
closed_trades = Trade.get_trades(Trade.is_open.is_(False)).all()
open_trades = Trade.get_trades(Trade.is_open.is_(True)).all()
tot_profit = sum([trade.calc_profit() for trade in closed_trades])
tot_in_trades = sum([trade.stake_amount for trade in open_trades])
current_stake = self.start_cap + tot_profit
current_stake = self.start_cap + tot_profit - tot_in_trades
self._wallets[self._config['stake_currency']] = Wallet(
self._config['stake_currency'],
current_stake,
0,
current_stake
)
open_trades = Trade.get_trades(Trade.is_open.is_(True)).all()
for trade in open_trades:
curr = trade.pair.split('/')[0]
trade.amount
self._wallets[curr] = Wallet(
curr,
trade.amount,