adding get_free to wallet
This commit is contained in:
parent
a9f04609d3
commit
29347a6931
@ -337,7 +337,7 @@ class FreqtradeBot(object):
|
|||||||
else:
|
else:
|
||||||
stake_amount = self.config['stake_amount']
|
stake_amount = self.config['stake_amount']
|
||||||
|
|
||||||
avaliable_amount = self.wallets.wallets[self.config['stake_currency']].free
|
avaliable_amount = self.wallets.get_free(self.config['stake_currency'])
|
||||||
|
|
||||||
if stake_amount == constants.UNLIMITED_STAKE_AMOUNT:
|
if stake_amount == constants.UNLIMITED_STAKE_AMOUNT:
|
||||||
open_trades = len(Trade.query.filter(Trade.is_open.is_(True)).all())
|
open_trades = len(Trade.query.filter(Trade.is_open.is_(True)).all())
|
||||||
|
@ -14,7 +14,6 @@ from telegram import Chat, Message, Update
|
|||||||
from freqtrade.exchange.exchange_helpers import parse_ticker_dataframe
|
from freqtrade.exchange.exchange_helpers import parse_ticker_dataframe
|
||||||
from freqtrade.exchange import Exchange
|
from freqtrade.exchange import Exchange
|
||||||
from freqtrade.edge import Edge
|
from freqtrade.edge import Edge
|
||||||
from freqtrade.wallets import Wallet
|
|
||||||
from freqtrade.freqtradebot import FreqtradeBot
|
from freqtrade.freqtradebot import FreqtradeBot
|
||||||
|
|
||||||
logging.getLogger('').setLevel(logging.INFO)
|
logging.getLogger('').setLevel(logging.INFO)
|
||||||
@ -46,9 +45,9 @@ def get_patched_exchange(mocker, config, api_mock=None) -> Exchange:
|
|||||||
return exchange
|
return exchange
|
||||||
|
|
||||||
|
|
||||||
def patch_wallet(mocker, currency='BTC', free=999.9) -> None:
|
def patch_wallet(mocker, free=999.9) -> None:
|
||||||
mocker.patch('freqtrade.wallets.Wallet', MagicMock(
|
mocker.patch('freqtrade.wallets.Wallets.get_free', MagicMock(
|
||||||
return_value=Wallet('bittrex', currency, free, 100, 1000)
|
return_value=free
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,12 +26,20 @@ class Wallets(object):
|
|||||||
|
|
||||||
def __init__(self, exchange: Exchange) -> None:
|
def __init__(self, exchange: Exchange) -> None:
|
||||||
self.exchange = exchange
|
self.exchange = exchange
|
||||||
if self.exchange._conf['dry_run']:
|
self.wallets: Dict[str, Any] = {}
|
||||||
self.wallets: Dict[str, Any] = {'BTC': Wallet('Bittrex', 'BTC', 999.99, 100, 1000)}
|
|
||||||
else:
|
|
||||||
self.wallets: Dict[str, Any] = {}
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
def get_free(self, currency) -> float:
|
||||||
|
|
||||||
|
if self.exchange._conf['dry_run']:
|
||||||
|
return 999.9
|
||||||
|
|
||||||
|
balance = self.wallets.get(currency)
|
||||||
|
if balance and balance['free']:
|
||||||
|
return balance['free']
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
balances = self.exchange.get_balances()
|
balances = self.exchange.get_balances()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user