s/trade_thresholds/minimal_roi/

This commit is contained in:
gcarq 2017-05-20 21:30:42 +02:00
parent 763e05ff14
commit 4859bf18a3
5 changed files with 21 additions and 23 deletions

View File

@ -19,12 +19,11 @@ Persistence is achieved through sqlite.
* /cancel: cancels open order for given trade (currently disabled)
##### Config
`trade_thresholds` is a JSON object where the key is a duration
in minutes and the value is the minimum profit threshold in
percent whether the bot should sell. See the example below:
`minimal_roi` is a JSON object where the key is a duration
in minutes and the value is the minimum ROI in percent.
See the example below:
```
"trade_thresholds": {
"minimal_roi": {
"2880": 0.005, # Sell after 48 hours if there is at least 0.5% profit
"1440": 0.01, # Sell after 24 hours if there is at least 1% profit
"720": 0.02, # Sell after 12 hours if there is at least 2% profit

View File

@ -3,12 +3,10 @@
"stake_currency": "BTC",
"stake_amount": 0.05,
"dry_run": false,
"trade_thresholds": {
"minimal_roi": {
"2880": 0.005,
"1440": 0.01,
"720": 0.03,
"360": 0.05,
"0": 0.10
"720": 0.01,
"0": 0.02
},
"poloniex": {
"enabled": false,

View File

@ -151,7 +151,7 @@ def handle_trade(trade):
currency = trade.pair.split('_')[1]
balance = api_wrapper.get_balance(currency)
for duration, threshold in sorted(conf['trade_thresholds'].items()):
for duration, threshold in sorted(conf['minimal_roi'].items()):
duration, threshold = float(duration), float(threshold)
# Check if time matches and current rate is above threshold
time_diff = (datetime.utcnow() - trade.open_date).total_seconds() / 60

View File

@ -237,11 +237,14 @@ class TelegramHandler(object):
:return: None
"""
if conf['telegram'].get('enabled', False):
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:
logger.warning('Got Telegram NetworkError: {}! trying one more time'.format(e.message))
bot.send_message(conf['telegram']['chat_id'], msg, parse_mode=parse_mode)
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:
# 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))
bot.send_message(conf['telegram']['chat_id'], msg, parse_mode=parse_mode)
except Exception:
logger.exception('Exception occurred within Telegram API')

View File

@ -36,16 +36,14 @@ def validate_conf(conf):
raise ValueError('stake_amount must be a float')
if not isinstance(conf.get('dry_run'), bool):
raise ValueError('dry_run must be a boolean')
if not isinstance(conf.get('trade_thresholds'), dict):
raise ValueError('trade_thresholds must be a dict')
if not isinstance(conf.get('trade_thresholds'), dict):
raise ValueError('trade_thresholds must be a dict')
if not isinstance(conf.get('minimal_roi'), dict):
raise ValueError('minimal_roi must be a dict')
for i, (minutes, threshold) in enumerate(conf.get('trade_thresholds').items()):
for i, (minutes, threshold) in enumerate(conf.get('minimal_roi').items()):
if not isinstance(minutes, str):
raise ValueError('trade_thresholds[{}].key must be a string'.format(i))
raise ValueError('minimal_roi[{}].key must be a string'.format(i))
if not isinstance(threshold, float):
raise ValueError('trade_thresholds[{}].value must be a float'.format(i))
raise ValueError('minimal_roi[{}].value must be a float'.format(i))
if conf.get('telegram'):
telegram = conf.get('telegram')