fix期权链 Delta 改为从 opt-summary 拉取。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user