注意

  1. 操作功能前請先登入。
  2. 詳細功能請參考 API Reference/faccount

Open In Colab

下載範例 Notebook

1. 保證金查詢 (Margin)

使用 get_margin 方法查詢指定帳號的保證金權益數。 若查詢成功 (ok == True),回傳的資料位於 data 屬性中,型別為 List[FMargin]

# 查詢保證金
response = unitrade.faccount.get_margin(actno)

if response.ok:
    print(response.data)

# 回傳 FMarginResponse 資料結構範例
# ---------------------------------------------------
# FMarginResponse(ok=True, error='', data=[
#   FMargin(
#     account='1234567',                  # 帳號
#     currency='***',                     # 幣別
#     available_balance=281348836.0,      # 可用餘額
#     original_margin=13218455.0,         # 原始保證金
#     maintenance_margin=12016777.0,      # 維持保證金
#     today_balance=295422442.0,          # 今日餘額
#     net_value=302998382.0,              # 淨值
#     unrealized_pnl=7575940.0,           # 未平倉損益
#     today_intraday_unrealized_pnl=7575940.0, # 今日盤中浮動損益
#     risk_coefficient=2292.24,           # 風險係數
#     maintenance_rate=2353.95,           # 維持率
#     commission=1034.0,                  # 手續費
#     futures_tax=21.0,                   # 期交稅
#     deposit_withdrawal_amount=0.0,      # 存提金額
#     close_pnl=0.0,                      # 平倉損益
#     buy_option_market_value=341151.0,   # 買方選擇權市值
#     sell_option_market_value=0.0,       # 賣方選擇權市值
#     total_market_value_risk=2237.08,    # 總市值風險
#     account_total_market_value=303339533.0, # 帳戶總市值
#     ... (其他詳細欄位請參考 API 文件)
#   )
# ])          

2. 未平倉查詢 (Unliquidation)

使用 get_unliquidation 方法查詢指定帳號的未平倉明細。 若查詢成功,回傳資料為 FUnliquidation 物件列表。

# 查詢未平倉
response = unitrade.faccount.get_unliquidation(actno)

if response.ok:
    print(response.data)

# 回傳 FUnliquidationResponse 資料結構範例
# ---------------------------------------------------
# FUnliquidationResponse(ok=True, error='', data=[
#   FUnliquidation(
#     client_account='1234567',           # 帳號
#     exchange='CME',                     # 交易所
#     product_code_1='AD',                # 商品代號
#     product_year_month_1='202506',      # 商品年月
#     buy_sell_type_1='B',                # 買賣別
#     open_interest_1=41,                 # 未平倉量
#     deal_price_1=6016.1829268,          # 成交價
#     spot_price_1=0.0,                   # 即時價 (市價)
#     unrealized_pnl_1=-2466635.0,        # 未平倉損益
#     unrealized_pnl_ntd_1=-72856655.0,   # 未平倉損益-約當台幣
#     initial_margin_1=99220.0,           # 原始保證金
#     maintenance_margin_1=90200.0,       # 維持保證金
#     currency_1='USD',                   # 幣別
#     commission_1=635.0,                 # 手續費
#     net_open_interest_pnl_1=-2467282.7, # 淨未平倉損益
#     abbreviation='澳幣',                 # 商品簡稱
#     ...
#   ),
#   ...
# ]) 

3. 即時部位查詢 (Position)

使用 get_position 方法查詢指定帳號的即時部位彙總。此功能通常用於查詢當日沖銷或即時庫存狀態。

# 查詢即時部位 (需傳入帳號與幣別代碼,如 'NTT')
response = unitrade.faccount.get_position(actno, 'NTT')

if response.ok:
    print(response.data)

# 回傳 FPositionResponse 資料結構範例
# ---------------------------------------------------
# FPositionResponse(ok=True, error='', data=[
#   FPosition(
#     client_account='1234567',           # 客戶帳號
#     exchange='CBT',                     # 交易所 
#     product_code='C',                   # 商品代號
#     product_year_month='202507',        # 商品年月 
#     currency='USD',                     # 幣別
#     net_buy=2,                          # 淨買口數
#     net_sell=0,                         # 淨賣口數
#     average_deal_price=436.1,           # 成交均價
#     instant_price=490.1,                # 即時價
#     unrealized_pnl=5400.0,              # 未平倉損益
#     buyer_position=2,                   # 買方留倉
#     seller_position=0,                  # 賣方留倉
#     close_volume=0,                     # 平倉口數
#     close_pnl=0.0,                      # 平倉損益
#     abbreviation='玉米',                 # 商品簡稱
#     ...
#   ), 
#   ...
# ]) 


Back to top

支援Python版本: 3.7 3.8 3.9 3.10 3.11 3.12

支援 OS: Linux, macOS, Windows