time aggregate to only query for data necessary
improves the query by not creating a full trade object.
This commit is contained in:
parent
2218313f5c
commit
ad3c01736e
@ -309,16 +309,18 @@ class RPC:
|
||||
|
||||
for day in range(0, timescale):
|
||||
profitday = start_date - time_offset(day)
|
||||
trades = Trade.get_trades(trade_filter=[
|
||||
# Only query for necessary columns for performance reasons.
|
||||
trades = Trade.query.session.query(Trade.close_profit_abs).filter(
|
||||
Trade.is_open.is_(False),
|
||||
Trade.close_date >= profitday,
|
||||
Trade.close_date < (profitday + time_offset(1))
|
||||
]).order_by(Trade.close_date).all()
|
||||
).order_by(Trade.close_date).all()
|
||||
|
||||
curdayprofit = sum(
|
||||
trade.close_profit_abs for trade in trades if trade.close_profit_abs is not None)
|
||||
profit_units[profitday] = {
|
||||
'amount': curdayprofit,
|
||||
'trades': len(trades)
|
||||
'trades': len(trades),
|
||||
}
|
||||
|
||||
data = [
|
||||
|
Loading…
Reference in New Issue
Block a user