wallet sync drafted

This commit is contained in:
misagh
2018-11-17 18:47:13 +01:00
parent de57da3249
commit 69dd56b237
2 changed files with 44 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ from freqtrade import (DependencyException, OperationalException,
TemporaryError, __version__, constants, persistence)
from freqtrade.exchange import Exchange
from freqtrade.edge import Edge
from freqtrade.persistence import Trade
from freqtrade.persistence import Trade, Wallet
from freqtrade.rpc import RPCManager, RPCMessageType
from freqtrade.state import State
from freqtrade.strategy.interface import SellType
@@ -800,3 +800,17 @@ class FreqtradeBot(object):
# Send the message
self.rpc.send_msg(msg)
Trade.session.flush()
def update_wallets(self) -> bool:
wallets = self.exchange.get_balances()
for currency in wallets:
wallet = Wallet(
exchange=self.exchange._api.id,
currency=currency,
free=wallets[currency]['free'],
used=wallets[currency]['used'],
total=wallets[currency]['total']
)
Wallet.session.add(wallet)
Wallet.session.flush()