操作功能前請先登入
詳細功能請參考 API Reference/faccount
保證金查詢
使用 faccount.get_margin 方法查詢指定帳號的保證金。這個方法需要兩個參數:帳號和幣別。
執行查詢後,會回傳一個 FMarginResponse 物件,其中包含查詢的結果。
如果 ok == True,表示查詢成功,回傳的保證金資料可以從 data 中取得,其欄位請參考 FMargin 。
# 保證金查詢範例
query_reply_response = unitrade.faccount.get_margin(actno)
# FMarginResponse(ok=True, error='', data=[
# FMargin(
# total_count=15,\\總筆數
# current_count=1,\\現在筆數
# web_code='PF2',\\Web代號
# web_serial='000041',\\網路序號
# currency='***',\\幣別
# previous_day_balance=295423497.0,\\前日帳款餘額
# commission=1034.0,\\手續費
# exchange_rate=1.0,\\匯率
# futures_tax=21.0,\\期交稅
# deposit_withdrawal_amount=0.0,\\存提金額
# close_pnl=0.0,\\平倉損益
# unrealized_pnl=7575940.0,\\未平倉損益
# buy_option_market_value=341151.0,\\買方選擇權市值
# sell_option_market_value=0.0,\\賣方選擇權市值
# order_withholding_premium=0.0,\\下單預扣權利金
# today_premium_income_expense=0.0,\\當日權利金收支
# net_value=302998382.0,\\淨值
# original_margin=13218455.0,\\原始保證金
# maintenance_margin=12016777.0,\\維持保證金
# available_balance=281348836.0,\\可用餘額
# order_available_margin=0.0,\\下單可用保證金
# today_order_margin=855151.0,\\當日委託保證金
# performance_pnl=0.0,\\履約損益
# variable_premium=341151.0,\\變動權利金
# marking_time='000000',\\洗價時間
# additional_payment=289779927.0,\\追繳金額
# yesterday_unrealized_pnl=0.0,\\昨日未平倉損益
# today_intraday_unrealized_pnl=7575940.0,\\今日盤中浮動損益
# sell_vertical_spread_market_value=0.0,\\賣方垂直價差市值
# strike_payment=0.0,\\履約價款
# today_balance=295422442.0,\\今日餘額
# account_total_market_value=303339533.0,\\帳戶總市值
# full_original_margin=13218455.0,\\足額原始保證金
# total_market_value_risk=2237.08,\\總市值風險
# risk_coefficient=2292.24,\\風險係數
# maintenance_rate=2353.95,\\維持率
# company_type='F008000',\\公司別
# account='1234567',\\帳號
# group='',\\組別
# trader=''\\交易員),
# ...
# ])
未平倉查詢
使用 faccount.get_unliquidation 方法查詢指定帳號的未平倉。這個方法需要兩個參數:帳號和幣別。
執行查詢後,會回傳一個 FUnliquidationResponse 物件,其中包含查詢的結果。
如果 ok == True,表示查詢成功,回傳的未平倉資料可以從 data 中取得,其欄位請參考 FUnliquidation 。
#查詢未平倉
query_reply_response = unitrade.faccount.get_unliquidation(actno)
# FUnliquidationResponse(ok=True, error='', data=[
# FUnliquidation(
# total_count=15,\\總筆數
# current_count=1,\\現在筆數
# company_type='F008000',\\客戶帳號
# client_account='1234567',\\交易所
# exchange='CME',\\交易所
# buy_sell_type_1='B',\\買賣別1
# trade_type_1='0',\\交易種類1
# product_code_1='AD',\\商品代號
# product_year_month_1='202506',\\商品年月1
# strike_price_1=0.0,\\履約價1
# buy_sell_option_1='',\\買賣權1
# open_interest_1=41,\\未平倉量1
# settlement_price_1=0.0,\\結算價1
# spot_price_1=0.0,\\即時價1
# unrealized_pnl_1=-2466635.0,\\未平倉損益1
# initial_margin_1=99220.0,\\原始保證金1
# maintenance_margin_1=90200.0,\\維持保證金1
# currency_1='USD',\\幣別1
# deal_price_1=6016.1829268,\\成交價1
# broker_code='PHI',\\上手代號
# unrealized_pnl_ntd_1=-72856655.0,\\未平倉損益-約當台幣1
# commission_1=635.0,\\手續費1
# business_tax_1=12.7,\\營業稅1
# net_open_interest_pnl_1=-2467282.7,\\淨未平倉損益1
# net_open_interest_pnl_ntd_1=-72875789.0,\\淨未平倉損益-約當台幣1
# group='',\\組別
# trader='',\\交易員
# abbreviation='澳幣',\\簡稱
# backend_pricebase='1',\\後台Pricebase
# display_pricebase='1'\\顯示pricebase
#),
# ...])
即時部位查詢
使用 faccount.get_position 方法查詢指定帳號的即時部位。這個方法需要兩個參數:帳號和幣別。
執行查詢後,會回傳一個 FPositionResponse 物件,其中包含查詢的結果。
如果 ok == True,表示查詢成功,回傳的即時部位資料可以從 data 中取得,其欄位請參考 FPosition 。
#查詢即時部位
query_reply_response = unitrade.faccount.get_position(actno, 'NTT')
# FPositionResponse(ok=True, error='', data=[
# FPosition(
# total_count=15,\\總筆數
# current_count=1,\\現在筆數
# web_code='PF2',\\Web代號
# web_serial='000075',\\網路序號
# company_type='F008000',\\公司別
# client_account='1234567',\\客戶帳號
# exchange='CBT',\\交易所
# trade_type='0',\\交易種類
# product_code='C',\\商品代號
# product_year_month='202507',\\商品年月
# strike_price=0.0,\\履約價
# buy_sell_option='',\\買賣權
# net_buy=2,\\淨買
# net_sell=0,\\淨賣
# buyer_position=2,\\買方留倉
# seller_position=0,\\賣方留倉
# buyer_transaction=0,\\買方成交
# seller_transaction=0,\\賣方成交
# buyer_order=0,\\買方委託
# seller_order=0,\\賣方委託
# delivery_date='00000000',\\交割日期
# currency='USD',\\幣別
# average_deal_price=436.1,\\成交均價
# instant_price=490.1,\\即時價
# unrealized_pnl=5400.0,\\未平倉損益
# close_volume=0,\\平倉口數
# close_pnl=0.0,\\平倉損益
# group='',\\組別
# trader='',\\交易員
# abbreviation='玉米',\\簡稱
# price_base='4'\\Pricebase
#),
# ..])