Skip to content

Commit a2df8d2

Browse files
author
Tonny@Home
committed
fix: correctly calculate final estimated expenditure based on buy_count in order_gen.py
1 parent cb2a8e1 commit a2df8d2

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

quantpits/scripts/order_gen.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,13 @@ def main():
788788
print(f"📤 卖出 : {len(sell_orders)}")
789789
print(f"📥 买入 : {len(buy_orders)}")
790790
if buy_orders:
791-
total_buy = sum(o['estimated_amount'] for o in buy_orders)
792-
print(f"💰 预估支出 : {total_buy:,.2f}")
791+
amounts = sorted([o['estimated_amount'] for o in buy_orders])
792+
min_total = sum(amounts[:buy_count])
793+
max_total = sum(amounts[-buy_count:]) if len(amounts) >= buy_count else sum(amounts)
794+
if min_total == max_total:
795+
print(f"💰 预估支出 : {min_total:,.2f}")
796+
else:
797+
print(f"💰 预估支出 : {min_total:,.2f} ~ {max_total:,.2f}")
793798
if sell_orders:
794799
print(f"💰 预估回收 : {sell_amount:,.2f}")
795800

0 commit comments

Comments
 (0)