Lighten hub options snapshot by skipping history stats.
Monitor board only needs positions, balances, and targets; drop the OKX positions-history pull each poll, and surface timeout errors via msg. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,9 +10,9 @@ class OptionsHubLibTests(TestCase):
|
||||
self.assertFalse(out["enabled"])
|
||||
self.assertTrue(out["ok"])
|
||||
|
||||
@patch("lib.options.options_hub_lib._compute_options_stats", return_value={})
|
||||
@patch("lib.options.options_history_lib.load_options_history")
|
||||
@patch("lib.options.options_positions_lib.build_display_option_positions")
|
||||
def test_build_options_hub_snapshot_positions(self, mock_positions, _mock_stats):
|
||||
def test_build_options_hub_snapshot_positions(self, mock_positions, mock_history):
|
||||
mock_positions.return_value = [
|
||||
{
|
||||
"inst_id": "ETH-USD_UM-260703-1800-C",
|
||||
@@ -38,10 +38,17 @@ class OptionsHubLibTests(TestCase):
|
||||
"account_label": "OKX期权",
|
||||
}
|
||||
with patch("lib.options.options_target_lib.list_active_targets", return_value=[]):
|
||||
with patch("lib.options.options_target_lib.targets_by_inst", return_value={}):
|
||||
out = build_options_hub_snapshot(cfg)
|
||||
with patch("lib.options.options_target_lib.list_closing_targets", return_value=[]):
|
||||
with patch("lib.options.options_target_lib.targets_by_inst", return_value={}):
|
||||
with patch(
|
||||
"lib.hedge_plan.hedge_plan_db.active_options_targets_by_inst",
|
||||
return_value={},
|
||||
):
|
||||
out = build_options_hub_snapshot(cfg)
|
||||
self.assertTrue(out["ok"], out.get("msg"))
|
||||
self.assertEqual(out["position_count"], 1)
|
||||
self.assertEqual(out["upl_total_usdc"], 1.5)
|
||||
self.assertEqual(out["trading_usdc"], 9.5)
|
||||
self.assertEqual(out.get("target_monitors"), [])
|
||||
self.assertEqual(out.get("stats"), {})
|
||||
mock_history.assert_not_called()
|
||||
|
||||
Reference in New Issue
Block a user