Show trade record prices at exchange tick precision.
API enriches entry/SL/TP with price_to_precision display strings; OKX formatter now uses the same path as Gate/Binance. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -78,6 +78,25 @@ class RecordsListLibTest(unittest.TestCase):
|
||||
self.assertEqual(out["page"], 2)
|
||||
self.assertEqual(len(out["items"]), 5)
|
||||
|
||||
def test_price_display_enrich(self):
|
||||
from lib.instance.records_list_lib import enrich_trade_price_displays
|
||||
|
||||
item = {
|
||||
"symbol": "BTC/USDT",
|
||||
"trigger_price": 63902.0,
|
||||
"display_open_stop_loss": 64500.0,
|
||||
"effective_take_profit": 62800.0,
|
||||
}
|
||||
|
||||
def _fmt(sym, v):
|
||||
self.assertEqual(sym, "BTC/USDT")
|
||||
return f"{float(v):.1f}"
|
||||
|
||||
out = enrich_trade_price_displays(item, _fmt)
|
||||
self.assertEqual(out["trigger_price_display"], "63902.0")
|
||||
self.assertEqual(out["stop_loss_display"], "64500.0")
|
||||
self.assertEqual(out["take_profit_display"], "62800.0")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user