avoid single char variable names
This commit is contained in:
parent
e82f6e0da8
commit
06d92042fd
@ -107,8 +107,8 @@ def plot_dataframe(dataframe, pair):
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
# Three subplots sharing x axe
|
# Three subplots sharing x axe
|
||||||
f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
|
fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
|
||||||
f.suptitle(pair, fontsize=14, fontweight='bold')
|
fig.suptitle(pair, fontsize=14, fontweight='bold')
|
||||||
ax1.plot(dataframe.index.values, dataframe['close'], label='close')
|
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_30_ema'], label='EMA(60)')
|
||||||
ax1.plot(dataframe.index.values, dataframe['close_90_ema'], label='EMA(120)')
|
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
|
# Fine-tune figure; make subplots close to each other and hide x ticks for
|
||||||
# all but bottom plot.
|
# all but bottom plot.
|
||||||
f.subplots_adjust(hspace=0)
|
fig.subplots_adjust(hspace=0)
|
||||||
plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False)
|
plt.setp([a.get_xticklabels() for a in fig.axes[:-1]], visible=False)
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
4
main.py
4
main.py
@ -63,8 +63,8 @@ class TradeThread(threading.Thread):
|
|||||||
while not _should_stop:
|
while not _should_stop:
|
||||||
try:
|
try:
|
||||||
self._process()
|
self._process()
|
||||||
except (ConnectionError, JSONDecodeError, ValueError) as e:
|
except (ConnectionError, JSONDecodeError, ValueError) as error:
|
||||||
msg = 'Got {} during _process()'.format(e.__class__.__name__)
|
msg = 'Got {} during _process()'.format(error.__class__.__name__)
|
||||||
logger.exception(msg)
|
logger.exception(msg)
|
||||||
finally:
|
finally:
|
||||||
Session.flush()
|
Session.flush()
|
||||||
|
@ -304,10 +304,10 @@ class TelegramHandler(object):
|
|||||||
bot = bot or TelegramHandler.get_updater(conf).bot
|
bot = bot or TelegramHandler.get_updater(conf).bot
|
||||||
try:
|
try:
|
||||||
bot.send_message(conf['telegram']['chat_id'], msg, parse_mode=parse_mode)
|
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,
|
# Sometimes the telegram server resets the current connection,
|
||||||
# if this is the case we send the message again.
|
# 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)
|
bot.send_message(conf['telegram']['chat_id'], msg, parse_mode=parse_mode)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception('Exception occurred within Telegram API')
|
logger.exception('Exception occurred within Telegram API')
|
||||||
|
18
utils.py
18
utils.py
@ -17,8 +17,8 @@ def get_conf(filename='config.json'):
|
|||||||
"""
|
"""
|
||||||
global _cur_conf
|
global _cur_conf
|
||||||
if not _cur_conf:
|
if not _cur_conf:
|
||||||
with open(filename) as fp:
|
with open(filename) as file:
|
||||||
_cur_conf = json.load(fp)
|
_cur_conf = json.load(file)
|
||||||
validate_conf(_cur_conf)
|
validate_conf(_cur_conf)
|
||||||
return _cur_conf
|
return _cur_conf
|
||||||
|
|
||||||
@ -40,11 +40,11 @@ def validate_conf(conf):
|
|||||||
if not isinstance(conf.get('minimal_roi'), dict):
|
if not isinstance(conf.get('minimal_roi'), dict):
|
||||||
raise ValueError('minimal_roi must be a 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):
|
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):
|
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'):
|
if conf.get('telegram'):
|
||||||
telegram = conf.get('telegram')
|
telegram = conf.get('telegram')
|
||||||
@ -95,7 +95,7 @@ def validate_bittrex_pairs(pairs):
|
|||||||
data = Bittrex(None, None).get_markets()
|
data = Bittrex(None, None).get_markets()
|
||||||
if not data['success']:
|
if not data['success']:
|
||||||
raise RuntimeError('BITTREX: {}'.format(data['message']))
|
raise RuntimeError('BITTREX: {}'.format(data['message']))
|
||||||
available_markets = [m['MarketName'].replace('-', '_')for m in data['result']]
|
available_markets = [market['MarketName'].replace('-', '_')for market in data['result']]
|
||||||
for p in pairs:
|
for pair in pairs:
|
||||||
if p not in available_markets:
|
if pair not in available_markets:
|
||||||
raise ValueError('Invalid pair: {}'.format(p))
|
raise ValueError('Invalid pair: {}'.format(pair))
|
||||||
|
Loading…
Reference in New Issue
Block a user