use profit_ratio for mix_tag_performance
This commit is contained in:
@@ -1780,7 +1780,7 @@ class Trade(ModelBase, LocalTrade):
|
|||||||
.order_by(desc('profit_sum_abs'))
|
.order_by(desc('profit_sum_abs'))
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
return_list: List[Dict] = []
|
resp: List[Dict] = []
|
||||||
for id, enter_tag, exit_reason, profit, profit_abs, count in mix_tag_perf:
|
for id, enter_tag, exit_reason, profit, profit_abs, count in mix_tag_perf:
|
||||||
enter_tag = enter_tag if enter_tag is not None else "Other"
|
enter_tag = enter_tag if enter_tag is not None else "Other"
|
||||||
exit_reason = exit_reason if exit_reason is not None else "Other"
|
exit_reason = exit_reason if exit_reason is not None else "Other"
|
||||||
@@ -1788,24 +1788,25 @@ class Trade(ModelBase, LocalTrade):
|
|||||||
if (exit_reason is not None and enter_tag is not None):
|
if (exit_reason is not None and enter_tag is not None):
|
||||||
mix_tag = enter_tag + " " + exit_reason
|
mix_tag = enter_tag + " " + exit_reason
|
||||||
i = 0
|
i = 0
|
||||||
if not any(item["mix_tag"] == mix_tag for item in return_list):
|
if not any(item["mix_tag"] == mix_tag for item in resp):
|
||||||
return_list.append({'mix_tag': mix_tag,
|
resp.append({'mix_tag': mix_tag,
|
||||||
'profit_ratio': profit,
|
'profit_ratio': profit,
|
||||||
'profit_pct': round(profit * 100, 2),
|
'profit_pct': round(profit * 100, 2),
|
||||||
'profit_abs': profit_abs,
|
'profit_abs': profit_abs,
|
||||||
'count': count})
|
'count': count})
|
||||||
else:
|
else:
|
||||||
while i < len(return_list):
|
while i < len(resp):
|
||||||
if return_list[i]["mix_tag"] == mix_tag:
|
if resp[i]["mix_tag"] == mix_tag:
|
||||||
return_list[i] = {
|
resp[i] = {
|
||||||
'mix_tag': mix_tag,
|
'mix_tag': mix_tag,
|
||||||
'profit_ratio': profit + return_list[i]["profit"],
|
'profit_ratio': profit + resp[i]["profit_ratio"],
|
||||||
'profit_pct': round(profit + return_list[i]["profit"] * 100, 2),
|
'profit_pct': round(profit + resp[i]["profit_ratio"] * 100, 2),
|
||||||
'profit_abs': profit_abs + return_list[i]["profit_abs"],
|
'profit_abs': profit_abs + resp[i]["profit_abs"],
|
||||||
'count': 1 + return_list[i]["count"]}
|
'count': 1 + resp[i]["count"]
|
||||||
|
}
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
return return_list
|
return resp
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_best_pair(start_date: datetime = datetime.fromtimestamp(0)):
|
def get_best_pair(start_date: datetime = datetime.fromtimestamp(0)):
|
||||||
|
|||||||
Reference in New Issue
Block a user