for testing feature: percent from top of book or from ask/bid

This commit is contained in:
Nullart 2018-06-17 15:40:38 +08:00
parent e5ad5a6aaa
commit 735356197d
4 changed files with 18 additions and 6 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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']
},

View File

@ -254,6 +254,8 @@ class FreqtradeBot(object):
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')
orderBook = exchange.get_order_book(pair,self.config['bid_strategy']['book_order_top'])
@ -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:
"""