Show average profit and loss in option stats panel.

Expose avg_win and avg_loss from stats API and update chart labels and values to match the average-based P/L ratio.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-11 09:29:26 +08:00
parent bf2d668d3c
commit 68733eb4f9
4 changed files with 17 additions and 13 deletions
+2
View File
@@ -61,6 +61,8 @@ class OptionsStatsLibTests(TestCase):
self.assertEqual(out["win_count"], 1)
self.assertEqual(out["loss_count"], 1)
self.assertEqual(out["win_rate"], 50.0)
self.assertAlmostEqual(out["avg_win"], 1.2, places=4)
self.assertAlmostEqual(out["avg_loss"], 1.0, places=4)
self.assertAlmostEqual(out["avg_win_hold_sec"], 3600.0, delta=5.0)
self.assertAlmostEqual(out["avg_loss_hold_sec"], 3 * 3600.0, delta=5.0)
self.assertEqual(out["open_count"], 1)