diff --git a/config.json.example b/config.json.example index 671e29a4d..8ff849649 100644 --- a/config.json.example +++ b/config.json.example @@ -17,7 +17,8 @@ "bid_strategy": { "ask_last_balance": 0.0, "use_book_order": true, - "book_order_top": 6 + "book_order_top": 6, + "percent_from_top": 0.005 }, "ask_strategy":{ "use_book_order": true, diff --git a/config_full.json.example b/config_full.json.example index 8a031dd65..1dbed091f 100644 --- a/config_full.json.example +++ b/config_full.json.example @@ -21,7 +21,8 @@ "bid_strategy": { "ask_last_balance": 0.0, "use_book_order": true, - "book_order_top": 6 + "book_order_top": 6, + "percent_from_top": 0.005 }, "ask_strategy":{ "use_book_order": true, diff --git a/freqtrade/constants.py b/freqtrade/constants.py index dae7dd65c..495586077 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -73,7 +73,8 @@ CONF_SCHEMA = { 'exclusiveMaximum': False }, 'use_book_order': {'type': 'boolean'}, - 'book_order_top': {'type': 'number', 'maximum': 20, 'minimum': 1} + 'book_order_top': {'type': 'number', 'maximum': 20, 'minimum': 1}, + 'percent_from_top' : {'type': 'number', 'minimum': 0} }, 'required': ['ask_last_balance','use_book_order'] }, diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 13a72450b..26a360d50 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -253,6 +253,8 @@ class FreqtradeBot(object): else: balance = self.config['bid_strategy']['ask_last_balance'] ticker_rate = ticker['ask'] + balance * (ticker['last'] - ticker['ask']) + + used_rate = ticker_rate if self.config['bid_strategy']['use_book_order']: logger.info('Getting price from Order Book') @@ -263,11 +265,18 @@ class FreqtradeBot(object): logger.info('...book order bid rate %0.8f',orderBook_rate) if ticker_rate < orderBook_rate: logger.info('...using ticker rate instead %0.8f',ticker_rate ) - return ticker_rate - return orderBook_rate + used_rate = ticker_rate + used_rate = orderBook_rate else: logger.info('Using Last Ask / Last Price') - return ticker_rate + used_rate = ticker_rate + + logger.info('used rate %0.8f',used_rate) + + if self.config['bid_strategy']['percent_from_top'] > 0: + used_rate = self.analyze.trunc_num(used_rate - (used_rate * self.config['bid_strategy']['percent_from_top']),8) + logger.info('used rate xx %0.8f',used_rate) + return used_rate def create_trade(self) -> bool: """