查詢歷史成交
FilledHistory
輸入參數
| 參數 | 類別 | 說明 |
|---|---|---|
| account | Account | 帳號 |
| startDate | *string | 查詢開始日 (格式: YYYYMMDD) |
| endDate | *string (空值預設與開始日相同) | 查詢終止日 (格式: YYYYMMDD) |
info
每次查詢最大設定30日日期區間
Result 回傳
| 參數 | 類別 | 說明 |
|---|---|---|
| IsSuccess | bool | 是否成功 |
| Data | *[]FilledData | 回傳成交列表 |
| Message | *string | 當 IsSuccess = false 回傳錯誤訊息 |
成交資訊 FilledData 欄位
Return type : Object
| 參數 | 類別 | 說明 |
|---|---|---|
| Date | *string | 成交日期 |
| BranchNo | *string | 分公司代號 |
| Account | *string | 帳號 |
| SeqNo | *string | 委託單流水序號 (只有主動回報才回傳此欄位) |
| OrderNo | *string | 委託書號 |
| StockNo | *string | 股票代號 |
| BuySell | BsAction | 買賣別 : BsActionBuy 買 、 BsActionSell 賣 |
| FilledNo | *string | 成交流水號 |
| FilledAvgPrice | *string | 成交均價 |
| FilledQty | *int64 | 成交股數 |
| FilledPrice | *string | 成交單價 |
| OrderType | OrderType | 委託單類型 : OrderTypeStock 現股 、 OrderTypeMargin 融資 、 OrderTypeShort 融券 、 OrderTypeDayTrade 現股當沖 、 OrderTypeSbl 借券 |
| FilledTime | *string | 成交時間 |
| UserDef | *string | 自訂欄位 (只有主動回報才回傳此欄位) |
請求範例
package main
import (
"fmt"
"fubon"
)
func main() {
// 初始化 SDK 並登入
sdk := fubon.NewSDK()
// ... 登入、連線等初始化步驟 ...
// 查詢歷史成交
startDate := "20250401"
endDate := "20250501"
filledHis, err := sdk.Stock.FilledHistory(account, &startDate, &endDate)
// 錯誤處理
if err != nil {
fmt.Printf("❌ Filled History Format/Parse Error: %v (Type: %T)\n", err, err)
return
}
// 檢查是否成功
if !filledHis.IsSuccess {
message := "No message"
if filledHis.Message != nil {
message = *filledHis.Message
}
fmt.Printf("Filled history failed. Message: %s\n", message)
return
}
// 輸出歷史成交列表
if filledHis.Data != nil && len(*filledHis.Data) > 0 {
fmt.Printf("✅ Found %d filled records\n", len(*filledHis.Data))
for i, filled := range *filledHis.Data {
fmt.Printf("\n--- Filled %d ---\n", i+1)
fmt.Printf("Date: %s\n", *filled.Date)
fmt.Printf("OrderNo: %s\n", *filled.OrderNo)
fmt.Printf("StockNo: %s\n", *filled.StockNo)
fmt.Printf("BuySell: %v\n", filled.BuySell)
fmt.Printf("FilledQty: %d\n", *filled.FilledQty)
fmt.Printf("FilledPrice: %s\n", *filled.FilledPrice)
fmt.Printf("FilledAvgPrice: %s\n", *filled.FilledAvgPrice)
fmt.Printf("FilledTime: %s\n", *filled.FilledTime)
fmt.Printf("OrderType: %v\n", filled.OrderType)
if filled.UserDef != nil && *filled.UserDef != "" {
fmt.Printf("UserDef: %s\n", *filled.UserDef)
}
}
} else {
fmt.Println("No filled data returned.")
}
}
回傳範例
// FilledHistory 回傳結構
Result{
IsSuccess: true,
Message: nil,
Data: &[]FilledData{
{
Date: "2025/04/29", // 成交日期
BranchNo: "6460", // 分公司代號
Account: "26", // 帳號
SeqNo: nil, // 委託流水序號
OrderNo: "bA422", // 委託書號
StockNo: "1101", // 股票代號
BuySell: Sell, // 買賣別
FilledNo: "00000000001", // 成交流水號
FilledAvgPrice: "35.2", // 成交均價
FilledQty: 1000, // 成交股數
FilledPrice: "35.2", // 成交單價
OrderType: Stock, // 委託單類型
FilledTime: "10:31:00.931", // 成交時間
UserDef: nil, // 用戶自定義
},
// ... 更多成交記錄
},
}