V2.2.1: Membership & Billing, USDT TRC20 payment, VIP free indicators, AI Trading Radar, simplified strategy creation, system settings simplification, bug fixes and UI improvements
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Interactive Brokers Trading Module
|
||||
|
||||
Supports US stocks and Hong Kong stocks trading via TWS or IB Gateway.
|
||||
Supports US stocks trading via TWS or IB Gateway.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -76,10 +76,10 @@ curl -X POST http://localhost:5000/api/ibkr/order \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"symbol": "AAPL", "side": "buy", "quantity": 10, "marketType": "USStock"}'
|
||||
|
||||
# Limit order: sell 100 shares of Tencent
|
||||
# Limit order: sell 100 shares of MSFT
|
||||
curl -X POST http://localhost:5000/api/ibkr/order \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"symbol": "0700.HK", "side": "sell", "quantity": 100, "marketType": "HShare", "orderType": "limit", "price": 300}'
|
||||
-d '{"symbol": "MSFT", "side": "sell", "quantity": 100, "marketType": "USStock", "orderType": "limit", "price": 400}'
|
||||
```
|
||||
|
||||
### Get Positions
|
||||
@@ -93,7 +93,6 @@ curl http://localhost:5000/api/ibkr/positions
|
||||
| Market | Format | Examples |
|
||||
|--------|--------|----------|
|
||||
| US Stock | Ticker symbol | `AAPL`, `TSLA`, `GOOGL` |
|
||||
| HK Stock | `XXXX.HK` or digits | `0700.HK`, `00700`, `700` |
|
||||
|
||||
## Important Notes
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Interactive Brokers (IBKR) Trading Module
|
||||
|
||||
Supports US stocks and Hong Kong stocks trading via TWS or IB Gateway.
|
||||
Supports US stocks trading via TWS or IB Gateway.
|
||||
|
||||
Port Reference:
|
||||
- TWS Live: 7497, TWS Paper: 7496
|
||||
|
||||
@@ -180,7 +180,7 @@ class IBKRClient:
|
||||
|
||||
Args:
|
||||
symbol: Symbol code
|
||||
market_type: Market type (USStock, HShare)
|
||||
market_type: Market type (USStock)
|
||||
"""
|
||||
_ensure_ib_insync()
|
||||
|
||||
@@ -219,7 +219,7 @@ class IBKRClient:
|
||||
symbol: Symbol code (e.g., AAPL, 0700.HK)
|
||||
side: Direction ("buy" or "sell")
|
||||
quantity: Number of shares
|
||||
market_type: Market type ("USStock" or "HShare")
|
||||
market_type: Market type ("USStock")
|
||||
|
||||
Returns:
|
||||
OrderResult
|
||||
|
||||
@@ -13,7 +13,7 @@ def normalize_symbol(symbol: str, market_type: str) -> Tuple[str, str, str]:
|
||||
|
||||
Args:
|
||||
symbol: Symbol code in the system
|
||||
market_type: Market type (USStock, HShare)
|
||||
market_type: Market type (USStock)
|
||||
|
||||
Returns:
|
||||
(ib_symbol, exchange, currency)
|
||||
@@ -26,22 +26,6 @@ def normalize_symbol(symbol: str, market_type: str) -> Tuple[str, str, str]:
|
||||
# Use SMART routing for best execution
|
||||
return symbol, "SMART", "USD"
|
||||
|
||||
elif market_type == "HShare":
|
||||
# Hong Kong stock formats:
|
||||
# - 0700.HK -> 700
|
||||
# - 00700 -> 700
|
||||
# - 700 -> 700
|
||||
ib_symbol = symbol
|
||||
|
||||
# Remove .HK suffix
|
||||
if ib_symbol.endswith(".HK"):
|
||||
ib_symbol = ib_symbol[:-3]
|
||||
|
||||
# Remove leading zeros
|
||||
ib_symbol = ib_symbol.lstrip("0") or "0"
|
||||
|
||||
return ib_symbol, "SEHK", "HKD"
|
||||
|
||||
else:
|
||||
# Default to US stock
|
||||
return symbol, "SMART", "USD"
|
||||
@@ -59,15 +43,6 @@ def parse_symbol(symbol: str) -> Tuple[str, Optional[str]]:
|
||||
"""
|
||||
symbol = (symbol or "").strip().upper()
|
||||
|
||||
# HK stock: ends with .HK or all digits
|
||||
if symbol.endswith(".HK"):
|
||||
return symbol, "HShare"
|
||||
|
||||
# All digits (likely HK stock code)
|
||||
clean = symbol.lstrip("0")
|
||||
if clean.isdigit() and len(clean) <= 5:
|
||||
return symbol, "HShare"
|
||||
|
||||
# Default to US stock
|
||||
return symbol, "USStock"
|
||||
|
||||
@@ -83,8 +58,4 @@ def format_display_symbol(ib_symbol: str, exchange: str) -> str:
|
||||
Returns:
|
||||
Display symbol
|
||||
"""
|
||||
if exchange == "SEHK":
|
||||
# HK stock: pad to 4 digits, add .HK
|
||||
padded = ib_symbol.zfill(4)
|
||||
return f"{padded}.HK"
|
||||
return ib_symbol
|
||||
|
||||
Reference in New Issue
Block a user