币本位期权数据统计按指数折算为U,不再误标USDC导致0.00

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-21 06:17:55 +08:00
parent 9421ff7360
commit 893a2cc115
5 changed files with 149 additions and 75 deletions
+18
View File
@@ -84,3 +84,21 @@ class OptionsStatsLibTests(TestCase):
self.assertAlmostEqual(out["profit_loss_ratio"], 0.33, places=2)
self.assertEqual(out["open_count"], 1)
self.assertAlmostEqual(out["net_realized_pnl"], round(0.87 - 3.99 - 1.33, 4), places=4)
def test_compute_options_stats_coin_to_usdt(self):
history = [
{
"status": "closed",
"realized_pnl": 0.00078,
"premium_ccy": "ETH",
"margin_mode": "coin",
"inst_id": "ETH-USD-260822-2250-C",
"idx_px": 2280,
"created_at": "2026-08-20 08:00:00",
"closed_at": "2026-08-20 13:32:00",
}
]
out = compute_options_stats_from_history(history)
self.assertEqual(out["pnl_unit"], "U")
self.assertEqual(out["total_closed"], 1)
self.assertAlmostEqual(out["net_realized_pnl"], 0.00078 * 2280, places=4)