修复期权币本位高危缺陷:开仓估量、卖回封顶、握库超时与条件单嵌套锁。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""粉尘阈值 / 卖回封顶 / 买入增量逻辑相关单测."""
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from lib.options.options_spot_bridge_lib import (
|
||||
display_sellable_coin,
|
||||
is_sellable_spot_coin,
|
||||
spot_min_sell_sz,
|
||||
)
|
||||
|
||||
|
||||
class TestSpotDust(unittest.TestCase):
|
||||
def test_min_sz_fallback(self):
|
||||
self.assertAlmostEqual(spot_min_sell_sz(None, "ETH"), 0.0001)
|
||||
self.assertAlmostEqual(spot_min_sell_sz(None, "BTC"), 0.00001)
|
||||
|
||||
def test_dust_not_sellable(self):
|
||||
self.assertFalse(is_sellable_spot_coin(None, "ETH", 0.000004))
|
||||
self.assertFalse(is_sellable_spot_coin(None, "BTC", 0.000002))
|
||||
self.assertEqual(display_sellable_coin(None, "ETH", 0.000004), 0.0)
|
||||
|
||||
def test_above_min_sellable(self):
|
||||
self.assertTrue(is_sellable_spot_coin(None, "ETH", 0.0001))
|
||||
self.assertTrue(is_sellable_spot_coin(None, "BTC", 0.00001))
|
||||
self.assertGreater(display_sellable_coin(None, "ETH", 0.001), 0)
|
||||
|
||||
|
||||
class TestSellCapLogic(unittest.TestCase):
|
||||
def test_excess_cap_math(self):
|
||||
bought, keep = 0.01, 0.004
|
||||
excess = max(0.0, bought - keep)
|
||||
self.assertAlmostEqual(excess, 0.006)
|
||||
sell_amt = min(0.02, excess)
|
||||
self.assertAlmostEqual(sell_amt, 0.006)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user