flake8 compliance
This commit is contained in:
parent
dc03b41c68
commit
79dd0eb104
@ -59,8 +59,8 @@ CONF_SCHEMA = {
|
|||||||
'type': 'object',
|
'type': 'object',
|
||||||
'properties': {
|
'properties': {
|
||||||
'use_book_order': {'type': 'boolean'},
|
'use_book_order': {'type': 'boolean'},
|
||||||
'buy': {'type': 'number', 'minimum':3},
|
'buy': {'type': 'number', 'minimum': 3},
|
||||||
'sell': {'type': 'number', 'minimum':10}
|
'sell': {'type': 'number', 'minimum': 10}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'bid_strategy': {
|
'bid_strategy': {
|
||||||
@ -73,7 +73,7 @@ CONF_SCHEMA = {
|
|||||||
'exclusiveMaximum': False
|
'exclusiveMaximum': False
|
||||||
},
|
},
|
||||||
'use_book_order': {'type': 'boolean'},
|
'use_book_order': {'type': 'boolean'},
|
||||||
'book_order_top': {'type': 'number', 'maximum':20,'minimum':1}
|
'book_order_top': {'type': 'number', 'maximum': 20, 'minimum': 1}
|
||||||
},
|
},
|
||||||
'required': ['ask_last_balance']
|
'required': ['ask_last_balance']
|
||||||
},
|
},
|
||||||
@ -81,8 +81,8 @@ CONF_SCHEMA = {
|
|||||||
'type': 'object',
|
'type': 'object',
|
||||||
'properties': {
|
'properties': {
|
||||||
'use_book_order': {'type': 'boolean'},
|
'use_book_order': {'type': 'boolean'},
|
||||||
'book_order_min': {'type': 'number', 'minimum':1},
|
'book_order_min': {'type': 'number', 'minimum': 1},
|
||||||
'book_order_max': {'type': 'number', 'minimum':1}
|
'book_order_max': {'type': 'number', 'minimum': 1}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'exchange': {'$ref': '#/definitions/exchange'},
|
'exchange': {'$ref': '#/definitions/exchange'},
|
||||||
|
@ -239,6 +239,7 @@ def get_balances() -> dict:
|
|||||||
except ccxt.BaseError as e:
|
except ccxt.BaseError as e:
|
||||||
raise OperationalException(e)
|
raise OperationalException(e)
|
||||||
|
|
||||||
|
|
||||||
@retrier
|
@retrier
|
||||||
def get_order_book(pair: str, limit: Optional[int] = 1000) -> dict:
|
def get_order_book(pair: str, limit: Optional[int] = 1000) -> dict:
|
||||||
try:
|
try:
|
||||||
@ -253,6 +254,7 @@ def get_order_book(pair: str, limit: Optional[int] = 1000) -> dict:
|
|||||||
except ccxt.BaseError as e:
|
except ccxt.BaseError as e:
|
||||||
raise OperationalException(e)
|
raise OperationalException(e)
|
||||||
|
|
||||||
|
|
||||||
@retrier
|
@retrier
|
||||||
def get_tickers() -> Dict:
|
def get_tickers() -> Dict:
|
||||||
try:
|
try:
|
||||||
|
@ -247,7 +247,7 @@ class FreqtradeBot(object):
|
|||||||
:return: float: Price
|
:return: float: Price
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ticker = exchange.get_ticker(pair);
|
ticker = exchange.get_ticker(pair)
|
||||||
if ticker['ask'] < ticker['last']:
|
if ticker['ask'] < ticker['last']:
|
||||||
return ticker['ask']
|
return ticker['ask']
|
||||||
balance = self.config['bid_strategy']['ask_last_balance']
|
balance = self.config['bid_strategy']['ask_last_balance']
|
||||||
@ -265,7 +265,6 @@ class FreqtradeBot(object):
|
|||||||
logger.info('Using Ask / Last Price')
|
logger.info('Using Ask / Last Price')
|
||||||
return ticker_rate
|
return ticker_rate
|
||||||
|
|
||||||
|
|
||||||
def create_trade(self) -> bool:
|
def create_trade(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Checks the implemented trading indicator(s) for a randomly picked pair,
|
Checks the implemented trading indicator(s) for a randomly picked pair,
|
||||||
@ -452,9 +451,12 @@ with limit `{buy_limit:.8f} ({stake_amount:.6f} \
|
|||||||
logger.info('Using order book for selling...')
|
logger.info('Using order book for selling...')
|
||||||
orderBook = exchange.get_order_book(trade.pair)
|
orderBook = exchange.get_order_book(trade.pair)
|
||||||
# logger.debug('Order book %s',orderBook)
|
# 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):
|
orderBook_min = self.config['ask_strategy']['book_order_min']
|
||||||
|
orderBook_max = self.config['ask_strategy']['book_order_max']
|
||||||
|
for i in range(orderBook_min, orderBook_max+1):
|
||||||
orderBook_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 orderbook has higher rate (high profit),
|
||||||
|
# use orderbook, otherwise just use sell rate
|
||||||
if (sell_rate < orderBook_rate):
|
if (sell_rate < orderBook_rate):
|
||||||
sell_rate = orderBook_rate
|
sell_rate = orderBook_rate
|
||||||
if self.check_sell(trade, sell_rate, buy, sell):
|
if self.check_sell(trade, sell_rate, buy, sell):
|
||||||
@ -467,7 +469,7 @@ with limit `{buy_limit:.8f} ({stake_amount:.6f} \
|
|||||||
logger.info('Found no sell signals for whitelisted currencies. Trying again..')
|
logger.info('Found no sell signals for whitelisted currencies. Trying again..')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_sell(self, trade: Trade, sell_rate: float, buy: bool, sell: bool ) -> bool:
|
def check_sell(self, trade: Trade, sell_rate: float, buy: bool, sell: bool) -> bool:
|
||||||
if self.analyze.should_sell(trade, sell_rate, datetime.utcnow(), buy, sell):
|
if self.analyze.should_sell(trade, sell_rate, datetime.utcnow(), buy, sell):
|
||||||
self.execute_sell(trade, sell_rate)
|
self.execute_sell(trade, sell_rate)
|
||||||
return True
|
return True
|
||||||
@ -488,7 +490,7 @@ with limit `{buy_limit:.8f} ({stake_amount:.6f} \
|
|||||||
try:
|
try:
|
||||||
# FIXME: Somehow the query above returns results
|
# FIXME: Somehow the query above returns results
|
||||||
# where the open_order_id is in fact None.
|
# where the open_order_id is in fact None.
|
||||||
# This is probably because the record got
|
# This is probably because the record get_trades_for_order
|
||||||
# updated via /forcesell in a different thread.
|
# updated via /forcesell in a different thread.
|
||||||
if not trade.open_order_id:
|
if not trade.open_order_id:
|
||||||
continue
|
continue
|
||||||
@ -502,7 +504,7 @@ with limit `{buy_limit:.8f} ({stake_amount:.6f} \
|
|||||||
ordertime = arrow.get(order['datetime']).datetime
|
ordertime = arrow.get(order['datetime']).datetime
|
||||||
|
|
||||||
# Check if trade is still actually open
|
# Check if trade is still actually open
|
||||||
if (int(order['filled']) == 0) and (order['status']=='open'):
|
if (int(order['filled']) == 0) and (order['status'] == 'open'):
|
||||||
if order['side'] == 'buy' and ordertime < buy_timeoutthreashold:
|
if order['side'] == 'buy' and ordertime < buy_timeoutthreashold:
|
||||||
self.handle_timedout_limit_buy(trade, order)
|
self.handle_timedout_limit_buy(trade, order)
|
||||||
elif order['side'] == 'sell' and ordertime < sell_timeoutthreashold:
|
elif order['side'] == 'sell' and ordertime < sell_timeoutthreashold:
|
||||||
|
@ -87,8 +87,8 @@ def default_conf():
|
|||||||
"stoploss": -0.10,
|
"stoploss": -0.10,
|
||||||
"disable_buy": False,
|
"disable_buy": False,
|
||||||
"unfilledtimeout": {
|
"unfilledtimeout": {
|
||||||
"buy":10,
|
"buy": 10,
|
||||||
"sell":30
|
"sell": 30
|
||||||
},
|
},
|
||||||
"bid_strategy": {
|
"bid_strategy": {
|
||||||
"use_book_order": False,
|
"use_book_order": False,
|
||||||
@ -253,7 +253,7 @@ def limit_buy_order():
|
|||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
'remaining': 0.0,
|
'remaining': 0.0,
|
||||||
'status': 'closed',
|
'status': 'closed',
|
||||||
'filled':0.0
|
'filled': 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ def limit_buy_order_old():
|
|||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
'remaining': 90.99181073,
|
'remaining': 90.99181073,
|
||||||
'status': 'open',
|
'status': 'open',
|
||||||
'filled':0.0
|
'filled': 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ def limit_sell_order_old():
|
|||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
'remaining': 90.99181073,
|
'remaining': 90.99181073,
|
||||||
'status': 'open',
|
'status': 'open',
|
||||||
'filled':0.0
|
'filled': 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ def limit_buy_order_old_partial():
|
|||||||
'amount': 90.99181073,
|
'amount': 90.99181073,
|
||||||
'remaining': 67.99181073,
|
'remaining': 67.99181073,
|
||||||
'status': 'open',
|
'status': 'open',
|
||||||
'filled':0.0
|
'filled': 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -502,7 +502,8 @@ def test_balance_fully_ask_side(mocker) -> None:
|
|||||||
"""
|
"""
|
||||||
Test get_target_bid() method
|
Test get_target_bid() method
|
||||||
"""
|
"""
|
||||||
freqtrade = get_patched_freqtradebot(mocker, {'bid_strategy': {'use_book_order':False,'book_order_top':6,'ask_last_balance': 0.0}})
|
param = {'use_book_order': False, 'book_order_top': 6, 'ask_last_balance': 0.0}
|
||||||
|
freqtrade = get_patched_freqtradebot(mocker, {'bid_strategy': param})
|
||||||
|
|
||||||
assert freqtrade.get_target_bid('ETH/BTC') >= 0.07
|
assert freqtrade.get_target_bid('ETH/BTC') >= 0.07
|
||||||
|
|
||||||
@ -511,7 +512,8 @@ def test_balance_fully_last_side(mocker) -> None:
|
|||||||
"""
|
"""
|
||||||
Test get_target_bid() method
|
Test get_target_bid() method
|
||||||
"""
|
"""
|
||||||
freqtrade = get_patched_freqtradebot(mocker, {'bid_strategy': {'use_book_order':False,'book_order_top':6,'ask_last_balance': 1.0}})
|
param = {'use_book_order': False, 'book_order_top': 6, 'ask_last_balance': 0.0}
|
||||||
|
freqtrade = get_patched_freqtradebot(mocker, {'bid_strategy': param})
|
||||||
|
|
||||||
assert freqtrade.get_target_bid('ETH/BTC') >= 0.07
|
assert freqtrade.get_target_bid('ETH/BTC') >= 0.07
|
||||||
|
|
||||||
@ -520,7 +522,8 @@ def test_balance_bigger_last_ask(mocker) -> None:
|
|||||||
"""
|
"""
|
||||||
Test get_target_bid() method
|
Test get_target_bid() method
|
||||||
"""
|
"""
|
||||||
freqtrade = get_patched_freqtradebot(mocker, {'bid_strategy': {'use_book_order':False,'book_order_top':6,'ask_last_balance': 1.0}})
|
param = {'use_book_order': False, 'book_order_top': 6, 'ask_last_balance': 0.0}
|
||||||
|
freqtrade = get_patched_freqtradebot(mocker, {'bid_strategy': param})
|
||||||
|
|
||||||
assert freqtrade.get_target_bid('ETH/BTC') >= 0.07
|
assert freqtrade.get_target_bid('ETH/BTC') >= 0.07
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user