fix sqlalchemy session to use contextual session

This commit is contained in:
Samuel Husso
2017-09-06 17:13:21 +03:00
parent 5bf244b92d
commit cb97a30087
3 changed files with 9 additions and 9 deletions

View File

@@ -124,7 +124,7 @@ class TelegramHandler(object):
profit_amounts.append((profit / 100) * trade.btc_amount)
profits.append(profit)
bp_pair, bp_rate = Session().query(Trade.pair, func.sum(Trade.close_profit).label('profit_sum')) \
bp_pair, bp_rate = Session.query(Trade.pair, func.sum(Trade.close_profit).label('profit_sum')) \
.filter(Trade.is_open.is_(False)) \
.group_by(Trade.pair) \
.order_by('profit_sum DESC') \
@@ -244,8 +244,7 @@ class TelegramHandler(object):
if not get_instance().is_alive():
TelegramHandler.send_msg('`trader is not running`', bot=bot)
return
pair_rates = Session().query(Trade.pair, func.sum(Trade.close_profit).label('profit_sum')) \
pair_rates = Session.query(Trade.pair, func.sum(Trade.close_profit).label('profit_sum')) \
.filter(Trade.is_open.is_(False)) \
.group_by(Trade.pair) \
.order_by('profit_sum DESC') \