added: disable_buy feature, this will only tell bot to sell whatever is needed to sell
added: order book buy and sell will check ticker first; for buying, if ticker is lower than buy order price, use ticker; for selling, if ticker is higher than sell order price, use ticker
This commit is contained in:
@@ -159,8 +159,11 @@ class FreqtradeBot(object):
|
||||
state_changed |= self.process_maybe_execute_sell(trade)
|
||||
|
||||
# Then looking for buy opportunities
|
||||
if len(trades) < self.config['max_open_trades']:
|
||||
state_changed = self.process_maybe_execute_buy()
|
||||
if (self.config['disable_buy']):
|
||||
logger.info('Buy disabled...')
|
||||
else:
|
||||
if len(trades) < self.config['max_open_trades']:
|
||||
state_changed = self.process_maybe_execute_buy()
|
||||
|
||||
if 'unfilledtimeout' in self.config:
|
||||
# Check and handle any timed out open orders
|
||||
@@ -244,17 +247,23 @@ class FreqtradeBot(object):
|
||||
:return: float: Price
|
||||
"""
|
||||
|
||||
ticker = exchange.get_ticker(pair);
|
||||
if ticker['ask'] < ticker['last']:
|
||||
return ticker['ask']
|
||||
balance = self.config['bid_strategy']['ask_last_balance']
|
||||
ticker_rate = ticker['ask'] + balance * (ticker['last'] - ticker['ask'])
|
||||
|
||||
if self.config['bid_strategy']['use_book_order']:
|
||||
logger.info('Getting price from Order Book')
|
||||
orderBook = exchange.get_order_book(pair)
|
||||
return orderBook['bids'][self.config['bid_strategy']['book_order_top']][0]
|
||||
orderBook_rate = orderBook['bids'][self.config['bid_strategy']['book_order_top']][0]
|
||||
# if ticker has lower rate, then use ticker ( usefull if down trending )
|
||||
if ticker_rate < orderBook_rate:
|
||||
return ticker_rate
|
||||
return orderBook_rate
|
||||
else:
|
||||
logger.info('Using Ask / Last Price')
|
||||
ticker = exchange.get_ticker(pair);
|
||||
if ticker['ask'] < ticker['last']:
|
||||
return ticker['ask']
|
||||
balance = self.config['bid_strategy']['ask_last_balance']
|
||||
return ticker['ask'] + balance * (ticker['last'] - ticker['ask'])
|
||||
return ticker_rate
|
||||
|
||||
|
||||
def create_trade(self) -> bool:
|
||||
@@ -444,7 +453,10 @@ with limit `{buy_limit:.8f} ({stake_amount:.6f} \
|
||||
orderBook = exchange.get_order_book(trade.pair)
|
||||
# logger.debug('Order book %s',orderBook)
|
||||
for i in range(self.config['ask_strategy']['book_order_min'],self.config['ask_strategy']['book_order_max']+1):
|
||||
sell_rate = orderBook['asks'][i-1][0]
|
||||
orderBook_rate = orderBook['asks'][i-1][0]
|
||||
# if orderbook has higher rate (high profit), use orderbook, otherwise just use sell rate
|
||||
if (sell_rate < orderBook_rate):
|
||||
sell_rate = orderBook_rate
|
||||
if self.check_sell(trade, sell_rate, buy, sell):
|
||||
return True
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user