Install
openclaw skills install futu-clientClawHub Security found sensitive or high-impact capabilities. Review the scan results before using.
Provides a Python client to query stock positions, account info, place orders, and retrieve market data using the Futu OpenAPI.
openclaw skills install futu-clientThe futu-client skill provides a convenient client for querying stock positions, account info, placing orders, and more using Futu OpenAPI. It wraps the futu (futu-api) library to offer a simplified interface for trading and querying.
127.0.0.1:11111pip install futu-api| Category | Methods |
|---|---|
| Positions | get_positions - Get current positions |
| Account | get_account_info - Get account balance, buying power |
| Trading | place_order, modify_order, unlock_trade |
| Orders | get_orders - Today's orders |
| Deals | get_today_deals - Today's executed trades |
| History | get_history_orders, get_history_deals |
| Watchlists | get_watchlist, get_all_watchlists - Get self-selected stocks |
| Quotes | get_quote, get_market_snapshot |
| Trading Info | get_max_tradable_qty |
pip install futu-api pandas
Note: FutuOpenD must be running on your machine before using this skill.
from futu_client import FutuClient
from futu import TrdSide, OrderType, TrdEnv
# Create client
client = FutuClient()
# Get positions
positions = client.get_positions(trd_env=TrdEnv.REAL)
print(positions)
# Get account info
account = client.get_account_info()
print(f"Total assets: {account['total_assets']}")
print(f"Buying power: {account['power']}")
# Get today's deals
deals = client.get_today_deals()
print(deals)
# Place an order (for real trading, use TrdEnv.REAL)
# result = client.place_order(
# price=100.0,
# qty=100,
# code="HK.00700",
# trd_side=TrdSide.BUY,
# trd_env=TrdEnv.SIMULATE # Use SIMULATE for testing
# )
# Get quote
quote = client.get_quote("US.AAPL")
print(f"AAPL price: {quote['last_price']}")
client.close()
Returns current positions as a DataFrame with columns:
code: Stock codestock_name: Stock nameqty: Position quantitycan_sell_qty: Available to sellcost_price: Cost pricenominal_price: Current market pricepl_ratio: Profit/loss ratio (%)currency: Currency (HKD, USD, etc.)Returns account information as a dictionary:
total_assets: Total assetscash: Available cashpower: Buying powermarket_val: Position market valuecurrency: Account currencyPlace an order. Returns order result.
Parameters:
price: Order price (float)qty: Order quantity (int)code: Stock code (e.g., "HK.00700", "US.AAPL")trd_side: TrdSide.BUY or TrdSide.SELLorder_type: OrderType.NORMAL (default)trd_env: TrdEnv.REAL (real) or TrdEnv.SIMULATE (paper trading)Get real-time quote for a stock.
Get market snapshot for multiple stocks.
Get user's watchlist (self-selected stocks).
Parameters:
group_name: Watchlist group name. Common values:
Returns DataFrame with columns:
code: Stock codename: Stock namelot_size: Lot sizeGet all watchlist groups at once.
Returns dictionary mapping group names to DataFrames.
Example:
client = FutuClient()
all_watchlists = client.get_all_watchlists()
for name, df in all_watchlists.items():
print(f"{name}: {len(df)} stocks")
client.close()
Always handle exceptions appropriately:
from futu_client import FutuClient
client = FutuClient()
try:
positions = client.get_positions()
except Exception as e:
print(f"Error: {e}")
client.close()