move order_book config out of experimental

This commit is contained in:
Nullart2
2018-08-29 17:38:43 +08:00
parent 4dfaf1d284
commit b6b89a464f
7 changed files with 92 additions and 109 deletions

View File

@@ -78,41 +78,35 @@ CONF_SCHEMA = {
'type': 'number',
'minimum': 0,
'maximum': 1,
'exclusiveMaximum': False
'exclusiveMaximum': False,
'use_order_book': {'type': 'boolean'},
'order_book_top': {'type': 'number', 'maximum': 20, 'minimum': 1},
'check_depth_of_market': {
'type': 'object',
'properties': {
'enabled': {'type': 'boolean'},
'bids_to_ask_delta': {'type': 'number', 'minimum': 0},
}
},
},
},
'required': ['ask_last_balance']
},
'ask_strategy': {
'type': 'object',
'properties': {
'use_order_book': {'type': 'boolean'},
'order_book_min': {'type': 'number', 'minimum': 1},
'order_book_max': {'type': 'number', 'minimum': 1, 'maximum': 50}
}
},
'exchange': {'$ref': '#/definitions/exchange'},
'experimental': {
'type': 'object',
'properties': {
'use_sell_signal': {'type': 'boolean'},
'sell_profit_only': {'type': 'boolean'},
'ignore_roi_if_buy_signal_true': {'type': 'boolean'},
'check_depth_of_market': {
'type': 'object',
'properties': {
'enabled': {'type': 'boolean'},
'bids_to_ask_delta': {'type': 'number', 'minimum': 0},
}
},
'bid_strategy': {
'type': 'object',
'properties': {
'percent_from_top': {'type': 'number', 'minimum': 0},
'use_order_book': {'type': 'boolean'},
'order_book_top': {'type': 'number', 'maximum': 20, 'minimum': 1}
}
},
'ask_strategy': {
'type': 'object',
'properties': {
'use_order_book': {'type': 'boolean'},
'order_book_min': {'type': 'number', 'minimum': 1},
'order_book_max': {'type': 'number', 'minimum': 1, 'maximum': 50}
}
}
'ignore_roi_if_buy_signal_true': {'type': 'boolean'}
}
},
'telegram': {

View File

@@ -247,11 +247,11 @@ class FreqtradeBot(object):
ticker_rate = ticker['ask'] + balance * (ticker['last'] - ticker['ask'])
used_rate = ticker_rate
experimental_bid_strategy = self.config.get('experimental', {}).get('bid_strategy', {})
if 'use_order_book' in experimental_bid_strategy and\
experimental_bid_strategy.get('use_order_book', False):
config_bid_strategy = self.config.get('bid_strategy', {})
if 'use_order_book' in config_bid_strategy and\
config_bid_strategy.get('use_order_book', False):
logger.info('Getting price from order book')
order_book_top = experimental_bid_strategy.get('order_book_top', 1)
order_book_top = config_bid_strategy.get('order_book_top', 1)
order_book = self.exchange.get_order_book(pair, order_book_top)
logger.debug('order_book %s', order_book)
# top 1 = index 0
@@ -359,11 +359,11 @@ class FreqtradeBot(object):
(buy, sell) = self.strategy.get_signal(_pair, interval, thistory)
if buy and not sell:
experimental_check_depth_of_market = self.config.get('experimental', {}).\
bidstrat_check_depth_of_market = self.config.get('bid_strategy', {}).\
get('check_depth_of_market', {})
if (experimental_check_depth_of_market.get('enabled', False)) and\
(experimental_check_depth_of_market.get('bids_to_ask_delta', 0) > 0):
if self._check_depth_of_market_buy(_pair, experimental_check_depth_of_market):
if (bidstrat_check_depth_of_market.get('enabled', False)) and\
(bidstrat_check_depth_of_market.get('bids_to_ask_delta', 0) > 0):
if self._check_depth_of_market_buy(_pair, bidstrat_check_depth_of_market):
return self.execute_buy(_pair, stake_amount)
else:
return False
@@ -551,12 +551,12 @@ class FreqtradeBot(object):
(buy, sell) = self.strategy.get_signal(trade.pair, self.strategy.ticker_interval,
ticker)
experimental_ask_strategy = self.config.get('experimental', {}).get('ask_strategy', {})
if experimental_ask_strategy.get('use_order_book', False):
config_ask_strategy = self.config.get('ask_strategy', {})
if config_ask_strategy.get('use_order_book', False):
logger.info('Using order book for selling...')
# logger.debug('Order book %s',orderBook)
order_book_min = experimental_ask_strategy.get('order_book_min', 1)
order_book_max = experimental_ask_strategy.get('order_book_max', 1)
order_book_min = config_ask_strategy.get('order_book_min', 1)
order_book_max = config_ask_strategy.get('order_book_max', 1)
order_book = self.exchange.get_order_book(trade.pair, order_book_max)

View File

@@ -102,7 +102,18 @@ def default_conf():
"sell": 30
},
"bid_strategy": {
"ask_last_balance": 0.0
"ask_last_balance": 0.0,
"use_order_book": False,
"order_book_top": 1,
"check_depth_of_market": {
"enabled": False,
"bids_to_ask_delta": 1
}
},
"ask_strategy": {
"use_order_book": False,
"order_book_min": 1,
"order_book_max": 1
},
"exchange": {
"name": "bittrex",
@@ -116,22 +127,6 @@ def default_conf():
"NEO/BTC"
]
},
"experimental": {
"check_depth_of_market": {
"enabled": False,
"bids_to_ask_delta": 1
},
"bid_strategy": {
"percent_from_top": 0,
"use_order_book": False,
"order_book_top": 1
},
"ask_strategy": {
"use_order_book": False,
"order_book_min": 1,
"order_book_max": 1
}
},
"telegram": {
"enabled": True,
"token": "token",

View File

@@ -1889,8 +1889,8 @@ def test_get_real_amount_open_trade(default_conf, mocker):
def test_order_book_depth_of_market(default_conf, ticker, limit_buy_order, fee, markets, mocker,
order_book_l2):
default_conf['experimental']['check_depth_of_market']['enabled'] = True
default_conf['experimental']['check_depth_of_market']['bids_to_ask_delta'] = 0.1
default_conf['bid_strategy']['check_depth_of_market']['enabled'] = True
default_conf['bid_strategy']['check_depth_of_market']['bids_to_ask_delta'] = 0.1
patch_RPCManager(mocker)
mocker.patch('freqtrade.exchange.Exchange.get_order_book', order_book_l2)
mocker.patch.multiple(
@@ -1924,9 +1924,9 @@ def test_order_book_depth_of_market(default_conf, ticker, limit_buy_order, fee,
def test_order_book_depth_of_market_high_delta(default_conf, ticker, limit_buy_order,
fee, markets, mocker, order_book_l2):
default_conf['experimental']['check_depth_of_market']['enabled'] = True
default_conf['bid_strategy']['check_depth_of_market']['enabled'] = True
# delta is 100 which is impossible to reach. hence check_depth_of_market will return false
default_conf['experimental']['check_depth_of_market']['bids_to_ask_delta'] = 100
default_conf['bid_strategy']['check_depth_of_market']['bids_to_ask_delta'] = 100
patch_RPCManager(mocker)
mocker.patch('freqtrade.exchange.Exchange.get_order_book', order_book_l2)
mocker.patch.multiple(
@@ -1958,8 +1958,8 @@ def test_order_book_bid_strategy1(mocker, default_conf, order_book_l2, markets)
get_order_book=order_book_l2
)
default_conf['exchange']['name'] = 'binance'
default_conf['experimental']['bid_strategy']['use_order_book'] = True
default_conf['experimental']['bid_strategy']['order_book_top'] = 2
default_conf['bid_strategy']['use_order_book'] = True
default_conf['bid_strategy']['order_book_top'] = 2
default_conf['bid_strategy']['ask_last_balance'] = 0
default_conf['telegram']['enabled'] = False
@@ -1979,8 +1979,8 @@ def test_order_book_bid_strategy2(mocker, default_conf, order_book_l2, markets)
get_order_book=order_book_l2
)
default_conf['exchange']['name'] = 'binance'
default_conf['experimental']['bid_strategy']['use_order_book'] = True
default_conf['experimental']['bid_strategy']['order_book_top'] = 2
default_conf['bid_strategy']['use_order_book'] = True
default_conf['bid_strategy']['order_book_top'] = 2
default_conf['bid_strategy']['ask_last_balance'] = 0
default_conf['telegram']['enabled'] = False
@@ -2000,8 +2000,8 @@ def test_order_book_bid_strategy3(default_conf, mocker, order_book_l2, markets)
get_order_book=order_book_l2
)
default_conf['exchange']['name'] = 'binance'
default_conf['experimental']['bid_strategy']['use_order_book'] = True
default_conf['experimental']['bid_strategy']['order_book_top'] = 1
default_conf['bid_strategy']['use_order_book'] = True
default_conf['bid_strategy']['order_book_top'] = 1
default_conf['bid_strategy']['ask_last_balance'] = 0
default_conf['telegram']['enabled'] = False
@@ -2022,12 +2022,12 @@ def test_check_depth_of_market_buy(default_conf, mocker, order_book_l2, markets)
)
default_conf['telegram']['enabled'] = False
default_conf['exchange']['name'] = 'binance'
default_conf['experimental']['check_depth_of_market']['enabled'] = True
default_conf['bid_strategy']['check_depth_of_market']['enabled'] = True
# delta is 100 which is impossible to reach. hence function will return false
default_conf['experimental']['check_depth_of_market']['bids_to_ask_delta'] = 100
default_conf['bid_strategy']['check_depth_of_market']['bids_to_ask_delta'] = 100
freqtrade = FreqtradeBot(default_conf)
conf = default_conf['experimental']['check_depth_of_market']
conf = default_conf['bid_strategy']['check_depth_of_market']
assert freqtrade._check_depth_of_market_buy('ETH/BTC', conf) is False
@@ -2038,9 +2038,9 @@ def test_order_book_ask_strategy(default_conf, limit_buy_order, limit_sell_order
"""
mocker.patch('freqtrade.exchange.Exchange.get_order_book', order_book_l2)
default_conf['exchange']['name'] = 'binance'
default_conf['experimental']['ask_strategy']['use_order_book'] = True
default_conf['experimental']['ask_strategy']['order_book_min'] = 1
default_conf['experimental']['ask_strategy']['order_book_max'] = 2
default_conf['ask_strategy']['use_order_book'] = True
default_conf['ask_strategy']['order_book_min'] = 1
default_conf['ask_strategy']['order_book_max'] = 2
default_conf['telegram']['enabled'] = False
patch_RPCManager(mocker)
mocker.patch.multiple(