Skip to content

Commit 9c8ff1f

Browse files
musingfoxclaude
andcommitted
refactor: remove unnecessary debug logs
- Remove verbose debug logs from positions and account info functions - Keep only essential connection and error logs - Clean up output to reduce noise in production usage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f431bb4 commit 9c8ff1f

3 files changed

Lines changed: 0 additions & 23 deletions

File tree

src/shioaji_mcp/server.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ async def handle_get_account_info() -> list[Any]:
236236
acc_type = "unknown"
237237
if hasattr(account, "account_type"):
238238
acc_type_str = str(account.account_type).upper()
239-
logger.info(f"Account {account.account_id}: type='{acc_type_str}'")
240239

241240
# Handle both enum string format and short code format
242241
if "STOCK" in acc_type_str or acc_type_str == "S":
@@ -245,8 +244,6 @@ async def handle_get_account_info() -> list[Any]:
245244
acc_type = "futures"
246245
elif acc_type_str == "H" or "HONG" in acc_type_str:
247246
acc_type = "hk_stock"
248-
249-
logger.info(f"Final parsed type for {account.account_id}: {acc_type}")
250247

251248
account_data = {
252249
"account_id": account.account_id,

src/shioaji_mcp/tools/positions.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ async def get_positions(arguments: dict[str, Any]) -> list[Any]:
2121

2222
api = auth_manager.get_api()
2323
account_type = arguments.get("account_type", "all") # all, stock, futures
24-
logger.info(f"get_positions called with account_type: '{account_type}'")
2524

2625
try:
2726
from ..utils.shioaji_wrapper import get_shioaji
@@ -89,16 +88,13 @@ async def get_positions(arguments: dict[str, Any]) -> list[Any]:
8988
logger.warning(f"Failed to get stock positions: {e}")
9089

9190
# Get futures positions
92-
logger.info(f"Checking futures account: has_futopt_account={hasattr(api, 'futopt_account')}, futopt_account={getattr(api, 'futopt_account', None)}")
9391
if (
9492
account_type in ["all", "futures"]
9593
and hasattr(api, "futopt_account")
9694
and api.futopt_account
9795
):
9896
try:
99-
logger.info("Attempting to get futures positions...")
10097
futures_positions = api.list_positions(api.futopt_account)
101-
logger.info(f"Got {len(futures_positions)} futures positions")
10298
for i, position in enumerate(futures_positions):
10399
position_data = {
104100
"index": i
@@ -145,7 +141,6 @@ async def get_positions(arguments: dict[str, Any]) -> list[Any]:
145141
if pos.get("account_type") == account_type
146142
]
147143
all_positions = filtered_positions
148-
logger.info(f"Filtered to {len(all_positions)} positions for account_type: {account_type}")
149144

150145
if not all_positions:
151146
account_msg = (
@@ -210,21 +205,18 @@ async def get_account_balance(arguments: dict[str, Any]) -> list[Any]:
210205
continue
211206

212207
# Get balance for this account
213-
logger.info(f"Getting balance for account {getattr(account, 'account_id', 'unknown')} type: {acc_type}")
214208
if (
215209
acc_type == "stock"
216210
and hasattr(api, "stock_account")
217211
and api.stock_account
218212
):
219213
balance = api.account_balance(api.stock_account)
220-
logger.info("Got stock account balance")
221214
elif (
222215
acc_type == "futures"
223216
and hasattr(api, "futopt_account")
224217
and api.futopt_account
225218
):
226219
balance = api.account_balance(api.futopt_account)
227-
logger.info("Got futures account balance")
228220
else:
229221
# Fallback - try with account directly
230222
balance = api.account_balance(account)

src/shioaji_mcp/utils/auth.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ def _auto_connect(self):
5959
secret_key=secret_key,
6060
)
6161

62-
# Check available accounts after login
63-
accounts = self.api.list_accounts()
64-
logger.info(f"Available accounts after login: {len(accounts)}")
65-
66-
for i, account in enumerate(accounts):
67-
account_type = getattr(account, 'account_type', 'unknown')
68-
logger.info(f"Account {i}: {account.account_id} - Type: {account_type}")
69-
70-
# Log stock and futures account shortcuts
71-
logger.info(f"Stock account shortcut: {getattr(self.api, 'stock_account', None)}")
72-
logger.info(f"Futopt account shortcut: {getattr(self.api, 'futopt_account', None)}")
73-
7462
self._is_connected = True
7563
logger.info("Successfully auto-connected to Shioaji")
7664

0 commit comments

Comments
 (0)