Use constants
This commit is contained in:
@@ -9,6 +9,7 @@ TICKER_INTERVAL = 5 # min
|
||||
HYPEROPT_EPOCH = 100 # epochs
|
||||
RETRY_TIMEOUT = 30 # sec
|
||||
DEFAULT_STRATEGY = 'DefaultStrategy'
|
||||
UNLIMITED_STAKE_AMOUNT = 'unlimited'
|
||||
|
||||
TICKER_INTERVAL_MINUTES = {
|
||||
'1m': 1,
|
||||
@@ -34,7 +35,7 @@ CONF_SCHEMA = {
|
||||
'stake_currency': {'type': 'string', 'enum': ['BTC', 'ETH', 'USDT']},
|
||||
'stake_amount': {'anyOf': [
|
||||
{'type': 'integer', 'minimum': 0.0005},
|
||||
{'constant': 'unlimited'}
|
||||
{'constant': UNLIMITED_STAKE_AMOUNT}
|
||||
]},
|
||||
'fiat_display_currency': {'type': 'string', 'enum': ['AUD', 'BRL', 'CAD', 'CHF',
|
||||
'CLP', 'CNY', 'CZK', 'DKK',
|
||||
|
@@ -259,7 +259,7 @@ class FreqtradeBot(object):
|
||||
stake_amount = self.config['stake_amount']
|
||||
avaliable_amount = exchange.get_balance(self.config['stake_currency'])
|
||||
|
||||
if stake_amount == 'unlimited':
|
||||
if stake_amount == constants.UNLIMITED_STAKE_AMOUNT:
|
||||
open_trades = len(Trade.query.filter(Trade.is_open.is_(True)).all())
|
||||
if open_trades == self.config['max_open_trades']:
|
||||
return 0
|
||||
|
@@ -13,7 +13,7 @@ from pandas import DataFrame
|
||||
from tabulate import tabulate
|
||||
|
||||
import freqtrade.optimize as optimize
|
||||
from freqtrade import exchange, DependencyException
|
||||
from freqtrade import exchange, constants, DependencyException
|
||||
from freqtrade.analyze import Analyze
|
||||
from freqtrade.arguments import Arguments
|
||||
from freqtrade.configuration import Configuration
|
||||
@@ -296,8 +296,9 @@ def setup_configuration(args: Namespace) -> Dict[str, Any]:
|
||||
config['exchange']['key'] = ''
|
||||
config['exchange']['secret'] = ''
|
||||
|
||||
if config['stake_amount'] == 'unlimited':
|
||||
raise DependencyException('stake amount could not be "unlimited" for backtesting')
|
||||
if config['stake_amount'] == constants.UNLIMITED_STAKE_AMOUNT:
|
||||
raise DependencyException('stake amount could not be "%s" for backtesting' %
|
||||
constants.UNLIMITED_STAKE_AMOUNT)
|
||||
|
||||
return config
|
||||
|
||||
|
@@ -15,7 +15,7 @@ import pytest
|
||||
import requests
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
from freqtrade import DependencyException, OperationalException, TemporaryError
|
||||
from freqtrade import constants, DependencyException, OperationalException, TemporaryError
|
||||
from freqtrade.freqtradebot import FreqtradeBot
|
||||
from freqtrade.persistence import Trade
|
||||
from freqtrade.state import State
|
||||
@@ -280,7 +280,7 @@ def test_get_trade_stake_amount_unlimited_amount(default_conf,
|
||||
)
|
||||
|
||||
conf = deepcopy(default_conf)
|
||||
conf['stake_amount'] = 'unlimited'
|
||||
conf['stake_amount'] = constants.UNLIMITED_STAKE_AMOUNT
|
||||
conf['max_open_trades'] = 2
|
||||
|
||||
freqtrade = FreqtradeBot(conf, create_engine('sqlite://'))
|
||||
|
Reference in New Issue
Block a user