|
|
@@ -3444,6 +3444,7 @@ def get_match_group_winlose_statistic(**qdata):
|
|
|
match_group_dct[item.id] = item.name
|
|
|
match_group_status_dct[item.id] = item.is_active
|
|
|
|
|
|
+ print(today)
|
|
|
prset = cm.PlayerRecord.get_db_model(match_id).objects.filter(match_id=match_id,stock_date=today)
|
|
|
|
|
|
group_win_lose_list = []
|
|
|
@@ -3451,13 +3452,16 @@ def get_match_group_winlose_statistic(**qdata):
|
|
|
prdata = prset.values("match_group").annotate(today_fund=Sum("today_fund"),
|
|
|
today_income=Sum("today_income"),cnt=Count("today_income")).order_by("match_group")
|
|
|
|
|
|
+ match_name = get_match_info(match_id).get("name")
|
|
|
+
|
|
|
for item in prdata:
|
|
|
group_id = int(item["match_group"])
|
|
|
if match_group_status_dct.get(group_id)>0:
|
|
|
group_win_lose_list.append({
|
|
|
"match_id":match_id,
|
|
|
+ "match_name":match_name,
|
|
|
"match_group":group_id,
|
|
|
- "match_group_name":match_group_dct.get(group_id),
|
|
|
+ "name":match_group_dct.get(group_id),
|
|
|
"today_fund":"{}".format(round(item["today_fund"],2)),
|
|
|
"today_income":"{}%".format(round(item["today_income"]*100,2)),
|
|
|
"today_income_avg":"{}%".format(round(item["today_income"]/item["cnt"]*100,2)) if item["cnt"] else 0.0
|
|
|
@@ -3544,29 +3548,46 @@ def get_match_group_winlose_allday(**qdata):
|
|
|
|
|
|
prset = cm.PlayerRecord.get_db_model(match_id).objects.filter(match_id=match_id,match_group=group_id)
|
|
|
|
|
|
- all_day = list(set(prset.values_list("stock_date",flat=True)))
|
|
|
- for stock_date in all_day:
|
|
|
- group_win_lose_list = []
|
|
|
- #今日总资产,总收益,平均收益
|
|
|
- prdata = prset.values("match_group","stock_date").annotate(today_fund=Sum("today_fund"),
|
|
|
- today_income=Sum("today_income"),cnt=Count("today_income")).order_by("match_group")
|
|
|
+ group_win_lose_list = []
|
|
|
+ prdata = prset.values("match_group","stock_date").annotate(today_fund=Sum("today_fund"),
|
|
|
+ today_income=Sum("today_income"),cnt=Count("today_income")).order_by("match_group").order_by("-stock_date")
|
|
|
|
|
|
- for item in prdata:
|
|
|
- group_id = int(item["match_group"])
|
|
|
- group_win_lose_list.append({
|
|
|
- "stock_date":stock_date,
|
|
|
- "match_group":group_id,
|
|
|
- "match_group_name":match_group_dct.get(group_id),
|
|
|
- "today_fund":"{}".format(round(item["today_fund"],2)),
|
|
|
- "today_income":"{}%".format(round(item["today_income"]*100,2)),
|
|
|
- "today_income_avg":"{}%".format(round(item["today_income"]/item["cnt"]*100,2)) if item["cnt"] else 0.0
|
|
|
- })
|
|
|
- #group_win_lose_list = sorted(group_win_lose_list,key=lambda x:x["match_group"],reverse=True)
|
|
|
+ for item in prdata:
|
|
|
+ group_id = int(item["match_group"])
|
|
|
+ stock_date = item["stock_date"]
|
|
|
+ group_win_lose_list.append({
|
|
|
+ "stock_date":stock_date,
|
|
|
+ "match_group":group_id,
|
|
|
+ "name":match_group_dct.get(group_id),
|
|
|
+ "today_fund":"{}".format(round(item["today_fund"],2)),
|
|
|
+ "total_income":"{}%".format(round(item["today_income"]/item["cnt"]*100,2)) if item["cnt"] else 0.0,
|
|
|
+ "today_income":"{}%".format(round(item["today_income"]/item["cnt"]*100,2)) if item["cnt"] else 0.0
|
|
|
+ })
|
|
|
|
|
|
- prset = cm.PlayerRecord.get_db_model(match_id).objects.filter(match_id=match_id,stock_date=today)
|
|
|
- #今日全部人均收益率
|
|
|
- total = prset.aggregate(total=Sum("today_income")).get("total")
|
|
|
- today_win_lose_avg = "{}%".format(round(total/prset.count()*100,2)) if prset.count()>0 else 0.0
|
|
|
+ rst = {"list":group_win_lose_list}
|
|
|
+ return rst
|
|
|
+
|
|
|
+
|
|
|
+def get_match_group_winlose_avg_allday(**qdata):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ match_id = qdata.get("match_id")
|
|
|
+ group_id = qdata.get("group_id")
|
|
|
+
|
|
|
+ prset = cm.PlayerRecord.get_db_model(match_id).objects.filter(match_id=match_id)
|
|
|
+
|
|
|
+ all_day = list(set(prset.values_list("stock_date",flat=True)))
|
|
|
+
|
|
|
+ allday_winlose_avg_list = []
|
|
|
+ for stock_date in all_day:
|
|
|
+ #今日全部人均收益率
|
|
|
+ total = prset.filter(stock_date=stock_date).aggregate(total=Sum("today_income")).get("total")
|
|
|
+ today_win_lose_avg = "{}%".format(round(total/prset.count()*100,2)) if prset.count()>0 else 0.0
|
|
|
+ allday_winlose_avg_list.append({
|
|
|
+ "stock_date":stock_date,
|
|
|
+ "today_income":today_win_lose_avg,
|
|
|
+ })
|
|
|
|
|
|
- rst = {"today_win_lose_avg":today_win_lose_avg,"group_win_lose_list":group_win_lose_list}
|
|
|
+ allday_winlose_avg_list = sorted(allday_winlose_avg_list,key=lambda x:x["stock_date"],reverse=True)
|
|
|
+ rst = {"list":allday_winlose_avg_list}
|
|
|
return rst
|