move logging to freqtrade.rpc

This commit is contained in:
gcarq 2017-11-18 21:43:21 +01:00
parent 3ab14dfe39
commit d41837817c
2 changed files with 12 additions and 8 deletions

View File

@ -119,15 +119,13 @@ def execute_sell(trade: Trade, limit: float) -> None:
trade.open_order_id = order_id
fmt_exp_profit = round(trade.calc_profit(limit) * 100, 2)
message = '*{}:* Selling [{}]({}) with limit `{:.8f} (profit: ~{:.2f}%)`'.format(
rpc.send_msg('*{}:* Selling [{}]({}) with limit `{:.8f} (profit: ~{:.2f}%)`'.format(
trade.exchange,
trade.pair.replace('_', '/'),
exchange.get_pair_detail_url(trade.pair),
limit,
fmt_exp_profit
)
logger.info(message)
rpc.send_msg(message)
))
def min_roi_reached(trade: Trade, current_rate: float, current_time: datetime) -> bool:
@ -214,14 +212,12 @@ def create_trade(stake_amount: float) -> Optional[Trade]:
order_id = exchange.buy(pair, buy_limit, amount)
# Create trade entity and return
message = '*{}:* Buying [{}]({}) with limit `{:.8f}`'.format(
rpc.send_msg('*{}:* Buying [{}]({}) with limit `{:.8f}`'.format(
exchange.get_name().upper(),
pair.replace('_', '/'),
exchange.get_pair_detail_url(pair),
buy_limit
)
logger.info(message)
rpc.send_msg(message)
))
# Fee is applied twice because we make a LIMIT_BUY and LIMIT_SELL
return Trade(pair=pair,
stake_amount=stake_amount,

View File

@ -1,5 +1,10 @@
import logging
from . import telegram
logger = logging.getLogger(__name__)
REGISTERED_MODULES = []
@ -11,6 +16,7 @@ def init(config: dict) -> None:
"""
if config['telegram'].get('enabled', False):
logger.info('Enabling rpc.telegram ...')
REGISTERED_MODULES.append('telegram')
telegram.init(config)
@ -21,6 +27,7 @@ def cleanup() -> None:
:return: None
"""
if 'telegram' in REGISTERED_MODULES:
logger.debug('Cleaning up rpc.telegram ...')
telegram.cleanup()
@ -30,5 +37,6 @@ def send_msg(msg: str) -> None:
:param msg: message
:return: None
"""
logger.info(msg)
if 'telegram' in REGISTERED_MODULES:
telegram.send_msg(msg)