Skip to content

Commit 9f5ad02

Browse files
author
Tonny@Home
committed
test: fix test error for requiring torch
1 parent d5efe25 commit 9f5ad02

File tree

3 files changed

+488
-9
lines changed

3 files changed

+488
-9
lines changed

quantpits/scripts/run_analysis.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def format_adv(val):
181181
discrepancy = exec_a.analyze_order_discrepancies(order_dir, market="all")
182182

183183
report.append("\n## 3. Execution Friction & Path Dependency")
184+
quant_slip_df = pd.DataFrame() # Initialize to avoid UnboundLocalError
184185
if not slip_df.empty:
185186
# Drop NaNs across all components simultaneously so denominators exactly match
186187
slip_df = slip_df.dropna(subset=['Delay_Cost', 'Exec_Slippage', 'Total_Friction', '成交金额'])
@@ -209,7 +210,7 @@ def weighted_avg(df, col, weight_col='成交金额'):
209210
if 'Absolute_Slippage_Amount' in buy_slip.columns and not args.shareable:
210211
abs_slip_buy = buy_slip['Absolute_Slippage_Amount'].sum()
211212
report.append(f" - Absolute Slippage Amount: {abs_slip_buy:.2f}")
212-
if 'ADV_Participation_Rate' in buy_slip.columns and not args.shareable:
213+
if 'ADV_Participation_Rate' in buy_slip.columns:
213214
buy_adv = buy_slip['ADV_Participation_Rate'].dropna()
214215
if not buy_adv.empty:
215216
report.append(f" - ADV Participation Rate (Mean / Max): {format_adv(buy_adv.mean())} / {format_adv(buy_adv.max())}")
@@ -225,7 +226,7 @@ def weighted_avg(df, col, weight_col='成交金额'):
225226
if 'Absolute_Slippage_Amount' in sell_slip.columns and not args.shareable:
226227
abs_slip_sell = sell_slip['Absolute_Slippage_Amount'].sum()
227228
report.append(f" - Absolute Slippage Amount: {abs_slip_sell:.2f}")
228-
if 'ADV_Participation_Rate' in sell_slip.columns and not args.shareable:
229+
if 'ADV_Participation_Rate' in sell_slip.columns:
229230
sell_adv = sell_slip['ADV_Participation_Rate'].dropna()
230231
if not sell_adv.empty:
231232
report.append(f" - ADV Participation Rate (Mean / Max): {format_adv(sell_adv.mean())} / {format_adv(sell_adv.max())}")

0 commit comments

Comments
 (0)