Add trading volume to /profit output

This commit is contained in:
Matthias
2022-06-18 11:40:32 +02:00
parent 6a15d36d14
commit 40c9abc7e1
4 changed files with 20 additions and 0 deletions

View File

@@ -1352,3 +1352,19 @@ class Trade(_DECL_BASE, LocalTrade):
.group_by(Trade.pair) \
.order_by(desc('profit_sum')).first()
return best_pair
@staticmethod
def get_trading_volume(start_date: datetime = datetime.fromtimestamp(0)) -> float:
"""
Get Trade volume based on Orders
NOTE: Not supported in Backtesting.
:returns: Tuple containing (pair, profit_sum)
"""
trading_volume = Order.query.with_entities(
func.sum(Order.cost).label('volume')
).filter(
(Order.order_filled_date >= start_date)
& (Order.status == 'closed')
) \
.scalar()
return trading_volume