futu-stock-mcp-server 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of futu-stock-mcp-server might be problematic. Click here for more details.
- futu_stock_mcp_server/server.py +39 -76
- {futu_stock_mcp_server-0.1.4.dist-info → futu_stock_mcp_server-0.1.5.dist-info}/METADATA +1 -1
- futu_stock_mcp_server-0.1.5.dist-info/RECORD +7 -0
- futu_stock_mcp_server-0.1.4.dist-info/RECORD +0 -7
- {futu_stock_mcp_server-0.1.4.dist-info → futu_stock_mcp_server-0.1.5.dist-info}/WHEEL +0 -0
- {futu_stock_mcp_server-0.1.4.dist-info → futu_stock_mcp_server-0.1.5.dist-info}/entry_points.txt +0 -0
- {futu_stock_mcp_server-0.1.4.dist-info → futu_stock_mcp_server-0.1.5.dist-info}/licenses/LICENSE +0 -0
futu_stock_mcp_server/server.py
CHANGED
|
@@ -569,87 +569,50 @@ def init_futu_connection() -> bool:
|
|
|
569
569
|
# Log to file only
|
|
570
570
|
logger.info(f"Initializing Futu connection to {host}:{port}")
|
|
571
571
|
|
|
572
|
-
#
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
572
|
+
# Initialize quote context
|
|
573
|
+
quote_ctx = OpenQuoteContext(host=host, port=port)
|
|
574
|
+
|
|
575
|
+
# Initialize trade context if needed
|
|
576
|
+
if os.getenv('FUTU_ENABLE_TRADING', '0') == '1':
|
|
577
|
+
# Get trading parameters
|
|
578
|
+
trade_env = os.getenv('FUTU_TRADE_ENV', 'SIMULATE')
|
|
579
|
+
security_firm = os.getenv('FUTU_SECURITY_FIRM', 'FUTUSECURITIES')
|
|
580
|
+
trd_market = os.getenv('FUTU_TRD_MARKET', 'HK')
|
|
581
|
+
|
|
582
|
+
# Map environment strings to Futu enums
|
|
583
|
+
trade_env_enum = {
|
|
584
|
+
'REAL': TrdMarket.REAL,
|
|
585
|
+
'SIMULATE': TrdMarket.SIMULATE
|
|
586
|
+
}.get(trade_env, TrdMarket.SIMULATE)
|
|
587
|
+
|
|
588
|
+
security_firm_enum = {
|
|
589
|
+
'FUTUSECURITIES': SecurityFirm.FUTUSECURITIES,
|
|
590
|
+
'FUTUINC': SecurityFirm.FUTUINC
|
|
591
|
+
}.get(security_firm, SecurityFirm.FUTUSECURITIES)
|
|
592
|
+
|
|
593
|
+
trd_market_enum = {
|
|
594
|
+
'HK': TrdMarket.HK,
|
|
595
|
+
'US': TrdMarket.US,
|
|
596
|
+
'CN': TrdMarket.CN,
|
|
597
|
+
'HKCC': TrdMarket.HKCC,
|
|
598
|
+
'AU': TrdMarket.AU
|
|
599
|
+
}.get(trd_market, TrdMarket.HK)
|
|
600
|
+
|
|
601
|
+
# Initialize trade context
|
|
602
|
+
trade_ctx = OpenSecTradeContext(
|
|
603
|
+
host=host,
|
|
604
|
+
port=port,
|
|
605
|
+
security_firm=security_firm_enum
|
|
606
|
+
)
|
|
607
|
+
_is_trade_initialized = True
|
|
608
|
+
logger.info("Trade context initialized successfully")
|
|
593
609
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
quote_ctx = OpenQuoteContext(host=host, port=port)
|
|
597
|
-
|
|
598
|
-
# Initialize trade context if needed
|
|
599
|
-
if os.getenv('FUTU_ENABLE_TRADING', '0') == '1':
|
|
600
|
-
# Get trading parameters
|
|
601
|
-
trade_env = os.getenv('FUTU_TRADE_ENV', 'SIMULATE')
|
|
602
|
-
security_firm = os.getenv('FUTU_SECURITY_FIRM', 'FUTUSECURITIES')
|
|
603
|
-
trd_market = os.getenv('FUTU_TRD_MARKET', 'HK')
|
|
604
|
-
|
|
605
|
-
# Map environment strings to Futu enums
|
|
606
|
-
trade_env_enum = {
|
|
607
|
-
'REAL': TrdMarket.REAL,
|
|
608
|
-
'SIMULATE': TrdMarket.SIMULATE
|
|
609
|
-
}.get(trade_env, TrdMarket.SIMULATE)
|
|
610
|
-
|
|
611
|
-
security_firm_enum = {
|
|
612
|
-
'FUTUSECURITIES': SecurityFirm.FUTUSECURITIES,
|
|
613
|
-
'FUTUINC': SecurityFirm.FUTUINC
|
|
614
|
-
}.get(security_firm, SecurityFirm.FUTUSECURITIES)
|
|
615
|
-
|
|
616
|
-
trd_market_enum = {
|
|
617
|
-
'HK': TrdMarket.HK,
|
|
618
|
-
'US': TrdMarket.US,
|
|
619
|
-
'CN': TrdMarket.CN,
|
|
620
|
-
'HKCC': TrdMarket.HKCC,
|
|
621
|
-
'AU': TrdMarket.AU
|
|
622
|
-
}.get(trd_market, TrdMarket.HK)
|
|
623
|
-
|
|
624
|
-
# Initialize trade context
|
|
625
|
-
trade_ctx = OpenSecTradeContext(
|
|
626
|
-
host=host,
|
|
627
|
-
port=port,
|
|
628
|
-
security_firm=security_firm_enum
|
|
629
|
-
)
|
|
630
|
-
_is_trade_initialized = True
|
|
631
|
-
logger.info("Trade context initialized successfully")
|
|
632
|
-
|
|
633
|
-
logger.info("Futu connection initialized successfully")
|
|
634
|
-
return True
|
|
635
|
-
|
|
636
|
-
finally:
|
|
637
|
-
# Restore stderr redirection
|
|
638
|
-
if futu_log_fd:
|
|
639
|
-
try:
|
|
640
|
-
futu_log_fd.close()
|
|
641
|
-
except:
|
|
642
|
-
pass
|
|
643
|
-
# Restore original stderr (should be devnull)
|
|
644
|
-
if original_stderr:
|
|
645
|
-
sys.stderr = original_stderr
|
|
610
|
+
logger.info("Futu connection initialized successfully")
|
|
611
|
+
return True
|
|
646
612
|
|
|
647
613
|
except Exception as e:
|
|
648
614
|
error_msg = f"Failed to initialize Futu connection: {str(e)}"
|
|
649
615
|
logger.error(error_msg)
|
|
650
|
-
# Make sure we restore stderr even in case of errors
|
|
651
|
-
if _stderr_redirected and _stderr_backup:
|
|
652
|
-
sys.stderr = _stderr_backup
|
|
653
616
|
return False
|
|
654
617
|
|
|
655
618
|
@asynccontextmanager
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: futu-stock-mcp-server
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: A Model Context Protocol (MCP) server for accessing Futu OpenAPI functionality
|
|
5
5
|
Project-URL: Homepage, https://github.com/shuizhengqi1/futu-stock-mcp-server
|
|
6
6
|
Project-URL: Documentation, https://github.com/shuizhengqi1/futu-stock-mcp-server#readme
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
futu_stock_mcp_server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
futu_stock_mcp_server/server.py,sha256=oMD3yHyBmECzqxQa7LU-QuPSDLkLo0RsluXACNeLKM0,65035
|
|
3
|
+
futu_stock_mcp_server-0.1.5.dist-info/METADATA,sha256=04hyGftEjBkbcpdA-zSJ3YoZmzUKGf6HtTSQJ76IMww,21041
|
|
4
|
+
futu_stock_mcp_server-0.1.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
5
|
+
futu_stock_mcp_server-0.1.5.dist-info/entry_points.txt,sha256=GAdKqPJD9dJ_fRA3e3m0NRia0elN5OcjEeAI30vOcIM,70
|
|
6
|
+
futu_stock_mcp_server-0.1.5.dist-info/licenses/LICENSE,sha256=XQBSQkjjpkymu_uLdyis4oNynV60VH1X7nS16uwM6g0,1069
|
|
7
|
+
futu_stock_mcp_server-0.1.5.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
futu_stock_mcp_server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
futu_stock_mcp_server/server.py,sha256=SokGZ3seYN1KwNozJqpbAmRsjcoYVSJ8v_wvMHu3pcs,66611
|
|
3
|
-
futu_stock_mcp_server-0.1.4.dist-info/METADATA,sha256=V8KxUH0ehGGfS7FtOGMH6t-kk1NYkKHhFLi3Vg84FO4,21041
|
|
4
|
-
futu_stock_mcp_server-0.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
5
|
-
futu_stock_mcp_server-0.1.4.dist-info/entry_points.txt,sha256=GAdKqPJD9dJ_fRA3e3m0NRia0elN5OcjEeAI30vOcIM,70
|
|
6
|
-
futu_stock_mcp_server-0.1.4.dist-info/licenses/LICENSE,sha256=XQBSQkjjpkymu_uLdyis4oNynV60VH1X7nS16uwM6g0,1069
|
|
7
|
-
futu_stock_mcp_server-0.1.4.dist-info/RECORD,,
|
|
File without changes
|
{futu_stock_mcp_server-0.1.4.dist-info → futu_stock_mcp_server-0.1.5.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{futu_stock_mcp_server-0.1.4.dist-info → futu_stock_mcp_server-0.1.5.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|