avoid single char variable names

This commit is contained in:
Janne Sinivirta 2017-08-27 16:40:27 +03:00
parent e82f6e0da8
commit 06d92042fd
4 changed files with 17 additions and 17 deletions

View File

@ -107,8 +107,8 @@ def plot_dataframe(dataframe, pair):
import matplotlib.pyplot as plt
# Three subplots sharing x axe
f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
f.suptitle(pair, fontsize=14, fontweight='bold')
fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
fig.suptitle(pair, fontsize=14, fontweight='bold')
ax1.plot(dataframe.index.values, dataframe['close'], label='close')
ax1.plot(dataframe.index.values, dataframe['close_30_ema'], label='EMA(60)')
ax1.plot(dataframe.index.values, dataframe['close_90_ema'], label='EMA(120)')
@ -129,8 +129,8 @@ def plot_dataframe(dataframe, pair):
# Fine-tune figure; make subplots close to each other and hide x ticks for
# all but bottom plot.
f.subplots_adjust(hspace=0)
plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False)
fig.subplots_adjust(hspace=0)
plt.setp([a.get_xticklabels() for a in fig.axes[:-1]], visible=False)
plt.show()

View File

@ -63,8 +63,8 @@ class TradeThread(threading.Thread):
while not _should_stop:
try:
self._process()
except (ConnectionError, JSONDecodeError, ValueError) as e:
msg = 'Got {} during _process()'.format(e.__class__.__name__)
except (ConnectionError, JSONDecodeError, ValueError) as error:
msg = 'Got {} during _process()'.format(error.__class__.__name__)
logger.exception(msg)
finally:
Session.flush()

View File

@ -304,10 +304,10 @@ class TelegramHandler(object):
bot = bot or TelegramHandler.get_updater(conf).bot
try:
bot.send_message(conf['telegram']['chat_id'], msg, parse_mode=parse_mode)
except NetworkError as e:
except NetworkError as error:
# Sometimes the telegram server resets the current connection,
# if this is the case we send the message again.
logger.warning('Got Telegram NetworkError: {}! trying one more time'.format(e.message))
logger.warning('Got Telegram NetworkError: {}! trying one more time'.format(error.message))
bot.send_message(conf['telegram']['chat_id'], msg, parse_mode=parse_mode)
except Exception:
logger.exception('Exception occurred within Telegram API')

View File

@ -17,8 +17,8 @@ def get_conf(filename='config.json'):
"""
global _cur_conf
if not _cur_conf:
with open(filename) as fp:
_cur_conf = json.load(fp)
with open(filename) as file:
_cur_conf = json.load(file)
validate_conf(_cur_conf)
return _cur_conf
@ -40,11 +40,11 @@ def validate_conf(conf):
if not isinstance(conf.get('minimal_roi'), dict):
raise ValueError('minimal_roi must be a dict')
for i, (minutes, threshold) in enumerate(conf.get('minimal_roi').items()):
for index, (minutes, threshold) in enumerate(conf.get('minimal_roi').items()):
if not isinstance(minutes, str):
raise ValueError('minimal_roi[{}].key must be a string'.format(i))
raise ValueError('minimal_roi[{}].key must be a string'.format(index))
if not isinstance(threshold, float):
raise ValueError('minimal_roi[{}].value must be a float'.format(i))
raise ValueError('minimal_roi[{}].value must be a float'.format(index))
if conf.get('telegram'):
telegram = conf.get('telegram')
@ -95,7 +95,7 @@ def validate_bittrex_pairs(pairs):
data = Bittrex(None, None).get_markets()
if not data['success']:
raise RuntimeError('BITTREX: {}'.format(data['message']))
available_markets = [m['MarketName'].replace('-', '_')for m in data['result']]
for p in pairs:
if p not in available_markets:
raise ValueError('Invalid pair: {}'.format(p))
available_markets = [market['MarketName'].replace('-', '_')for market in data['result']]
for pair in pairs:
if pair not in available_markets:
raise ValueError('Invalid pair: {}'.format(pair))