fix期权链 Delta 改为从 opt-summary 拉取。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-14 22:20:08 +08:00
parent 627c27a6f8
commit 4e14c92385
2 changed files with 52 additions and 5 deletions
+18 -1
View File
@@ -1,10 +1,27 @@
# -*- coding: utf-8 -*-
import unittest
from lib.exchange.okx_options_lib import format_position_row
from lib.exchange.okx_options_lib import format_position_row, option_delta_from_summary
class OptionsDeltaFieldsTests(unittest.TestCase):
def test_delta_prefers_summary_delta_bs(self):
self.assertAlmostEqual(
option_delta_from_summary({"deltaBS": "0.55", "delta": "12.3"}),
0.55,
places=4,
)
def test_delta_falls_back_to_ticker(self):
self.assertAlmostEqual(
option_delta_from_summary({}, ticker={"delta": "-0.22"}),
-0.22,
places=4,
)
def test_delta_none_when_missing(self):
self.assertIsNone(option_delta_from_summary({}, ticker={}))
def test_format_position_exposes_delta_bs(self):
row = format_position_row(
{